Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Sep 1998 23:54:01 +0200 (CEST)
From:      Udo Erdelhoff <ue@nathan.ruhr.de>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/7939: sed's substitute command fails if the replacement string is 4090 chars or longer
Message-ID:  <199809152154.XAA04640@nathan.ruhr.de>

next in thread | raw e-mail | index | archive | help

>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:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 15 15:10:01 PDT 1998
>Last-Modified:
>Originator:     Udo Erdelhoff
>Organization:
private site
>Release:        FreeBSD 2.2.7-STABLE i386
>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.

>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809152154.XAA04640>