[Toybox] [PATCH] Fix segfault in sed -e 'c\'

Rob Landley rob at landley.net
Mon Mar 7 07:55:12 PST 2016


On 03/06/2016 12:12 PM, Andy Chu wrote:
> I forgot to mention that GNU sed behaves differently on this case.
> I'm not sure if this is important.

Neither am I.

I applied your segfault fix, but I think I'll wait for somebody to show
something this part breaks?

> $ sed --version
> sed (GNU sed) 4.2.2
> ...
> 
> $ echo -e 'a\nb\nc\n' | sed -e 'c\'
> (no output)

Or more accurately:

$ echo -e 'a\nb\nc\nd' | sed -e '/b/c\'
a
c
d

I.E. treating 'c\' with no next line as 'd', and ignoring the error
condition rather than reporting it. Even gcc at least gives a warning:

$ echo '\' > hello2.c
$ gcc -c hello2.c
hello2.c:1:1: warning: backslash-newline at end of file [enabled by default]
 \
 ^

> $ echo -e 'a\nb\nc\n' | sed -e 'c\ '  # add space after \
> (4 blank lines)

Because they escaped a space. We do the same thing, c has data to output
so we output it.

> Andy

Thanks for the fix. Did your fuzzer find anything else?

Rob

 1457366112.0


More information about the Toybox mailing list