NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/42261: sed(1) command parser bug with long lines

>Number:         42261
>Category:       bin
>Synopsis:       sed(1) command parser bug with long lines
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 03 21:10:00 +0000 2009
>Originator:     Tobias Nygren
NetBSD 5.99.21 NetBSD 5.99.21 (GENERIC.mac) #7: Thu Oct 22 
10:51:26 CEST 2009 amd64
the sed(1) command parser seems to break on s/foo/bar/g commands that are 
exactly 2049 bytes long (coincidentally _POSIX2_LINE_MAX + 1)

The following shell script should output ${LONG_STR}, a string of 2043 x'es, 
but doesn't output anything. The "g" flag to the "s" command is treated as a 
new command.

#! /bin/sh
LONG_STR=$(awk 'BEGIN {while(x<2043){printf "x";x++}}')
echo x | sed s,x,${LONG_STR},g

Probably an off-by-one bug.
Needs to be pulled up to netbsd-5 when fixed.

Home | Main Index | Thread Index | Old Index