mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
Fixed calloc() and getopt_long()
Added integer overflow test to calloc(). Tiny change in getopt_long() so that the value pointed to by the "longindex" parameter is always initialized to an invalid index position (that being -1), instead of 0. The value of 0 can break some shell commands, most notably GNU wget.
This commit is contained in:
@ -296,7 +296,7 @@ static int getopt_long_internal(int argc, const char **argv, const char *optstri
|
||||
optp = strchr(optstring, c);
|
||||
|
||||
/* We never find a long option in a compound option */
|
||||
*longindex = 0;
|
||||
*longindex = -1;
|
||||
|
||||
/* Check if it's legal */
|
||||
if (c == ':' || (optp == NULL))
|
||||
|
||||
Reference in New Issue
Block a user