Hi folks,

I found a strange bug in stty. Admittedly, this is not a quite
sensible use of stty, but the following segfaults:

stty eof -

The reason is the way the options are parsed, so the "-" gets
recognized as an argument with valid options and argv[2] gets
set to NULL, but argc will still be 3. Then with k=1 the following
code executes:

 ++k;
 set_control_char (&control_info[i], argv[k], &mode);

and set_control_char() is not prepared to get a null pointer as
second argument. The same problem seems to occur at several other
places. I would suggest (as a quick fix) to substitute every occurence of

 if (k == argc - 1)

by 

 if (argv[k+1] == NULL )

This would instead of segfaulting complain about a missing argument
which is better IMHO. There could be other solutions depending on
the semantic one wishes to have or according to some strange standards
floating around.

Cheers, Lukas
-- 
Lukas Geyer <[EMAIL PROTECTED]>

_______________________________________________
Bug-sh-utils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-sh-utils

Reply via email to