[patch] segfault in sh for bogus redirection
Simon L. Nielsen
simon at FreeBSD.org
Sun Jul 13 23:24:40 UTC 2008
Hey Stefan (and other people familiar with the sh(1) code),
I stumbled on a corner case bug in sh(1) where it segfaults instead of
giving a proper error message. This only happens when you do
something stupid, but I thought it should be fixed anyway.
When you redirect to an unset or empty variable things fail:
$ sh -c 'echo 1 >&$a'
Segmentation fault (core dumped)
With patch:
$ sh -c 'echo 1 >&$a'
Syntax error: Bad fd number
I have made a patch which fixes the issue (attached) so it fails
normally with an error, but I'm not sure if it's the right way of
fixing it. Do you think this fix is OK, or is there a better way to
do this?
I also included a regression test to check for the problem.
--
Simon L. Nielsen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sh-redir-segv-0.patch
Type: text/x-diff
Size: 884 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20080713/40004e09/sh-redir-segv-0.bin
More information about the freebsd-current
mailing list