diff options
author | 2003-09-22 23:45:22 +0000 | |
---|---|---|
committer | 2003-09-22 23:45:22 +0000 | |
commit | d56aaea68bcf288ebbd0544da2fa397fcad8c100 (patch) | |
tree | ae82269f21a701bfa3d4acb1e3e33691752fb66a /lib/libc/stdlib/getopt_long.c | |
parent | Fix read beyond end of buffer, found by mallocguard. ok deraadt@ espie@ (diff) | |
download | wireguard-openbsd-d56aaea68bcf288ebbd0544da2fa397fcad8c100.tar.xz wireguard-openbsd-d56aaea68bcf288ebbd0544da2fa397fcad8c100.zip |
If permutation is disabled (as it is via getopt(3) or when POSIXLY_CORRECT
is set), we can accept an optional arg separated by whitespace. Previously,
the optional arg needed to be adjacent to the option character.
deraadt@ OK
Diffstat (limited to 'lib/libc/stdlib/getopt_long.c')
-rw-r--r-- | lib/libc/stdlib/getopt_long.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libc/stdlib/getopt_long.c b/lib/libc/stdlib/getopt_long.c index 124893051ca..1f7f5baa8b5 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.14 2003/06/17 21:56:24 millert Exp $ */ +/* $OpenBSD: getopt_long.c,v 1.15 2003/09/22 23:45:22 millert Exp $ */ /* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ /* @@ -57,7 +57,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: getopt_long.c,v 1.14 2003/06/17 21:56:24 millert Exp $"; +static char *rcsid = "$OpenBSD: getopt_long.c,v 1.15 2003/09/22 23:45:22 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <err.h> @@ -472,6 +472,13 @@ start: return (BADARG); } else optarg = nargv[optind]; + } else if (!(flags & FLAG_PERMUTE)) { + /* + * If permutation is disabled, we can accept an + * optional arg separated by whitespace. + */ + if (optind + 1 < nargc) + optarg = nargv[++optind]; } place = EMSG; ++optind; |