bug-sh-utils
[Top][All Lists]
Advanced

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

Bug in stty (GNU sh-utils 2.0): Segfault related to option parsing


From: Lukas Geyer
Subject: Bug in stty (GNU sh-utils 2.0): Segfault related to option parsing
Date: 11 May 2001 16:15:04 +0200

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 <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]