summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/getopt.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2002-12-08 17:52:26 +0000
committermillert <millert@openbsd.org>2002-12-08 17:52:26 +0000
commit6777ee373625fe22e6742b7e5e70a0cdac6e3dfd (patch)
treec7cef78a109bef2aa3fb08d8c74acef8740ecb9e /lib/libc/stdlib/getopt.c
parentduh, provide a wrapper on the hardclock() since it's void (diff)
downloadwireguard-openbsd-6777ee373625fe22e6742b7e5e70a0cdac6e3dfd.tar.xz
wireguard-openbsd-6777ee373625fe22e6742b7e5e70a0cdac6e3dfd.zip
SUS (and apparently 1003.1-2001) say to check optstring for NULL
Diffstat (limited to 'lib/libc/stdlib/getopt.c')
-rw-r--r--lib/libc/stdlib/getopt.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c
index b7f61636623..218887dd32f 100644
--- a/lib/libc/stdlib/getopt.c
+++ b/lib/libc/stdlib/getopt.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: getopt.c,v 1.2 1996/08/19 08:33:32 tholo Exp $";
+static char *rcsid = "$OpenBSD: getopt.c,v 1.3 2002/12/08 17:52:26 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -63,6 +63,9 @@ getopt(nargc, nargv, ostr)
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
+ if (options == NULL)
+ return (-1);
+
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {