From ue@nathan.ruhr.de  Tue Sep 15 15:01:30 1998
Received: from mail.ruhrgebiet.individual.net (in-ruhr.ruhr.de [141.39.224.38])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA17695
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 15 Sep 1998 15:01:27 -0700 (PDT)
          (envelope-from ue@nathan.ruhr.de)
Received: (from admin@localhost)
	by mail.ruhrgebiet.individual.net (8.8.5-r-beta/8.8.5) with UUCP id XAA26415
	for FreeBSD-gnats-submit@freebsd.org; Tue, 15 Sep 1998 23:59:56 +0200 (MET DST)
Received: (from ue@localhost)
	by nathan.ruhr.de (8.8.8/8.8.8) id XAA04640;
	Tue, 15 Sep 1998 23:54:01 +0200 (CEST)
	(envelope-from ue)
Message-Id: <199809152154.XAA04640@nathan.ruhr.de>
Date: Tue, 15 Sep 1998 23:54:01 +0200 (CEST)
From: Udo Erdelhoff <ue@nathan.ruhr.de>
Reply-To: ue@nathan.ruhr.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: sed's substitute command fails if the replacement string is 4090 chars or longer
X-Send-Pr-Version: 3.2

>Number:         7939
>Category:       bin
>Synopsis:       sed's substitute command fails if the replacement string is 4090 chars or longer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 15 15:10:01 PDT 1998
>Closed-Date:    Sun Dec 6 21:36:18 PST 1998
>Last-Modified:  Sun Dec  6 21:37:09 PST 1998
>Originator:     Udo Erdelhoff
>Release:        FreeBSD 2.2.7-STABLE i386
>Organization:
private site
>Environment:

FreeBSD-stable as of ctm-842 (08/08/98)
sed version (strings /usr/bin/sed | grep Id):
$Id: compile.c,v 1.8.2.1 1997/08/12 06:36:11 charnier Exp $
$Id: main.c,v 1.3.2.4 1998/03/08 12:13:03 jkh Exp $
$Id: misc.c,v 1.1.1.1.8.1 1997/08/12 06:36:12 charnier Exp $
$Id: process.c,v 1.5.2.2 1998/07/17 04:21:21 jkh Exp $

>Description:

I'm currently testing an email/news gateway system. sed is used to create
input files with long addresses/message-ID to check for buffer overruns
and other unwanted behaviour. It's supposed to replace specific tags with
several hundred/thousand As. In other words:
sed "s/<some tag>/<some thousand A>/g" < input-file > output-file 
If I try to replace the tag with 4090 characters, sed doesn't produce any
output. If the replacement field is longer than 4090 bytes, sed simply
deletes the tag.

>How-To-Repeat:
Create an input file named "foo" containing the text BBXXXBB
Run sed "s/XXX/<4090 characters>/g" < foo
-> sed creates no output
Run sed "s/XXX/<4091 characters/g" < foo
-> sed prints BBBB
Run sed "s/XXX/<4089 characters>/g" < foo
-> sed behaves correctly (i.e. BB<the characters>BB) 

I've included a sample (gzip'ed tarfile to protect the long line). The
sed command within the script bar.sh has a 4090 bytes long replacment
string and produces no output. Add another A to get an output where 
tag was discarded. Remove two As to get the correct result.

begin 644 sed-problem-demo.tar.gz
M'XL(`-'?_C4``^W8L0Z",!#&<6:>XL3=MDC;Q46>@A4BB(LD5-[?HHF;;F!"
M_K_EDNLEO>7KT&X8DJ49K5U12")BO-5S%<F+=WTQ6L19[ZVUSN6QX:W)$]&+
M;Q9-X5&/(LG4_IZ+8UVWQD+K*LNJJLHR_?<>^(^F'@^A7_:.F/\8[6_YCZ?'
M3_Z]<WYNY=J0_S7L=ZJYW57HT]!>)`LJ/@?J#```````MDM=,SE)-PS\!P(`
/`````&S$$XG-76D`*```
`
end

>Fix:
	
	GNU sed works fine.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: archie 
State-Changed-When: Sun Dec 6 21:36:18 PST 1998 
State-Changed-Why:  
Bug identified and fixed. Thanks for the report! 
>Unformatted:
