summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authormillert <>2004-06-03 18:46:52 +0000
committermillert <>2004-06-03 18:46:52 +0000
commitbea8674d8fa57fb3227fdc5b14c3af3a00d97a20 (patch)
treedc1d120d827c885f3f7354691441dcfc35aec950 /src/lib
parentb449c9c2c7deee8a634ff1c3c2a9d33d0756fb59 (diff)
downloadopenbsd-bea8674d8fa57fb3227fdc5b14c3af3a00d97a20.tar.gz
openbsd-bea8674d8fa57fb3227fdc5b14c3af3a00d97a20.tar.bz2
openbsd-bea8674d8fa57fb3227fdc5b14c3af3a00d97a20.zip
An optional argument cannot start with '-', even if permutation is
disabled. Magne Oestlyngen.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/stdlib/getopt_long.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/libc/stdlib/getopt_long.c b/src/lib/libc/stdlib/getopt_long.c
index 6079ce3503..bf50195b94 100644
--- a/src/lib/libc/stdlib/getopt_long.c
+++ b/src/lib/libc/stdlib/getopt_long.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getopt_long.c,v 1.16 2004/02/04 18:17:25 millert Exp $ */ 1/* $OpenBSD: getopt_long.c,v 1.17 2004/06/03 18:46:52 millert Exp $ */
2/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ 2/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
3 3
4/* 4/*
@@ -57,7 +57,7 @@
57 */ 57 */
58 58
59#if defined(LIBC_SCCS) && !defined(lint) 59#if defined(LIBC_SCCS) && !defined(lint)
60static char *rcsid = "$OpenBSD: getopt_long.c,v 1.16 2004/02/04 18:17:25 millert Exp $"; 60static char *rcsid = "$OpenBSD: getopt_long.c,v 1.17 2004/06/03 18:46:52 millert Exp $";
61#endif /* LIBC_SCCS and not lint */ 61#endif /* LIBC_SCCS and not lint */
62 62
63#include <err.h> 63#include <err.h>
@@ -474,9 +474,10 @@ start:
474 } else if (!(flags & FLAG_PERMUTE)) { 474 } else if (!(flags & FLAG_PERMUTE)) {
475 /* 475 /*
476 * If permutation is disabled, we can accept an 476 * If permutation is disabled, we can accept an
477 * optional arg separated by whitespace. 477 * optional arg separated by whitespace so long
478 * as it does not start with a dash (-).
478 */ 479 */
479 if (optind + 1 < nargc) 480 if (optind + 1 < nargc && *nargv[optind + 1] != '-')
480 optarg = nargv[++optind]; 481 optarg = nargv[++optind];
481 } 482 }
482 place = EMSG; 483 place = EMSG;