summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/getopt_long.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_long.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_long.c')
-rw-r--r--lib/libc/stdlib/getopt_long.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/stdlib/getopt_long.c b/lib/libc/stdlib/getopt_long.c
index 176ba25bb7d..413ec24f4e4 100644
--- a/lib/libc/stdlib/getopt_long.c
+++ b/lib/libc/stdlib/getopt_long.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getopt_long.c,v 1.9 2002/12/08 17:07:46 millert Exp $ */
+/* $OpenBSD: getopt_long.c,v 1.10 2002/12/08 17:52:26 millert Exp $ */
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
/*
@@ -64,7 +64,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: getopt_long.c,v 1.9 2002/12/08 17:07:46 millert Exp $";
+static char *rcsid = "$OpenBSD: getopt_long.c,v 1.10 2002/12/08 17:52:26 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <err.h>
@@ -301,7 +301,8 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
int optchar, short_too;
static int posixly_correct = -1;
- optarg = NULL;
+ if (options == NULL)
+ return (-1);
/*
* Disable GNU extensions if POSIXLY_CORRECT is set or options
@@ -323,6 +324,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
if (optind == 0)
optind = optreset = 1;
+ optarg = NULL;
if (optreset)
nonopt_start = nonopt_end = -1;
start: