From 572f8c85ab40c2adf389a33ea6f2f91c4a4fbb30 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Wed, 27 Jan 2016 21:52:25 -0800 Subject: 37810: repair handling of backslashes and of names starting with "+"/":"/"=" in zparseopts option specs --- Src/Modules/zutil.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Src/Modules') diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index d98028a84..12a4c03e9 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -1745,13 +1745,15 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) for (p = o; *p; p++) { if (*p == '\\' && p[1]) p++; - else if (*p == '+') { - f |= ZOF_MULT; - *p = '\0'; - p++; - break; - } else if (*p == ':' || *p == '=') - break; + else if (p > o) { /* At least one character of option name */ + if (*p == '+') { + f |= ZOF_MULT; + *p = '\0'; + p++; + break; + } else if (*p == ':' || *p == '=') + break; + } } if (*p == ':') { f |= ZOF_ARG; @@ -1789,6 +1791,7 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) p++; *n++ = *p; } + *n = '\0'; if (get_opt_desc(o)) { zwarnnam(nam, "option defined more than once: %s", o); return 1; -- cgit 1.4.1