mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-25 07:32:06 +03:00
fix getopt wrongly treating colons in optstring as valid option chars
the ':' in optstring has special meaning as a flag applying to the previous option character, or to getopt's error handling behavior when it appears at the beginning. don't also accept a "-:" option based on its presence.
This commit is contained in:
parent
82f176803a
commit
b123f23952
@ -77,7 +77,7 @@ int getopt(int argc, char * const argv[], const char *optstring)
|
||||
if (l>0) i+=l; else i++;
|
||||
} while (l && d != c);
|
||||
|
||||
if (d != c) {
|
||||
if (d != c || c == ':') {
|
||||
optopt = c;
|
||||
if (optstring[0] != ':' && opterr)
|
||||
__getopt_msg(argv[0], ": unrecognized option: ", optchar, k);
|
||||
|
Loading…
Reference in New Issue
Block a user