projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
82f1768
)
fix getopt wrongly treating colons in optstring as valid option chars
author
Rich Felker
<dalias@aerifal.cx>
Sat, 24 Feb 2018 15:26:26 +0000
(10:26 -0500)
committer
Rich Felker
<dalias@aerifal.cx>
Sat, 24 Feb 2018 15:26:26 +0000
(10:26 -0500)
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.
src/misc/getopt.c
patch
|
blob
|
history
diff --git
a/src/misc/getopt.c
b/src/misc/getopt.c
index e9bab41cccf00075788dc4783fa880c60dd62c28..e921a60ed9997ac0634f1a4c819ce55c7b18714d 100644
(file)
--- 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);