diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-02-24 10:26:26 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-02-24 10:26:26 -0500 |
commit | b123f2395266a44176e49cee251fb776e97f26e1 (patch) | |
tree | 31663a69a638ffc289a0e878938bafc9cc2b4fa1 /src | |
parent | 82f176803ae07e34229906d5c7c62889e665dc97 (diff) | |
download | musl-b123f2395266a44176e49cee251fb776e97f26e1.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/misc/getopt.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/misc/getopt.c b/src/misc/getopt.c index e9bab41c..e921a60e 100644 --- a/src/misc/getopt.c +++ b/src/misc/getopt.c @@ -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); |