From: Rich Felker <dalias@aerifal.cx>
Date: Thu, 11 Dec 2014 02:29:01 +0000 (-0500)
Subject: fix getopt handling of initial '+' in optstring
X-Git-Tag: v1.1.6~32
X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d4f7d9c46f0e8f19d70871efb66b0f482935642d;p=oweals%2Fmusl.git

fix getopt handling of initial '+' in optstring

in the case where an initial '+' was passed in optstring (a
getopt_long feature to suppress argv permutation), getopt would fail
to see a possible subsequent ':', resulting in incorrect handling of
missing arguments.
---

diff --git a/src/misc/getopt.c b/src/misc/getopt.c
index 52aa7a3a..e77e460a 100644
--- a/src/misc/getopt.c
+++ b/src/misc/getopt.c
@@ -55,7 +55,7 @@ int getopt(int argc, char * const argv[], const char *optstring)
 		optpos = 0;
 	}
 
-	if (optstring[0] == '-')
+	if (optstring[0] == '-' || optstring[0] == '+')
 		optstring++;
 
 	i = 0;