Date: Tue, 14 Aug 2001 01:52:03 -0700 (PDT) From: jkoshy@FreeBSD.ORG (Joseph Koshy) To: freebsd-gnats-submit@FreeBSD.ORG Cc: freebsd-audit@FreeBSD.ORG Subject: Re: bin/29625: limits -d etc. should not output warning Message-ID: <20010814085203.2D2AC37B408@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
The problem turns out to be in our implementation of `getopt(3)'
and not in /usr/bin/limits.
If 'optstring' passed to getopt() starts with a leading ':', then getopt()
should not print a warning for missing arguments. The attached patch fixes
this.
Could someone on -audit please review?
Regards,
Koshy
<jkoshy@freebsd.org>
[-- Attachment #2 --]
Index: getopt.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/stdlib/getopt.c,v
retrieving revision 1.3
diff -u -r1.3 getopt.c
--- getopt.c 2000/09/04 03:49:22 1.3
+++ getopt.c 2001/08/14 08:25:54
@@ -65,7 +65,6 @@
extern char *__progname;
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
- int ret;
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
@@ -105,14 +104,12 @@
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':')
- ret = BADARG;
- else
- ret = BADCH;
+ return (BADARG);
if (opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
__progname, optopt);
- return (ret);
+ return (BADCH);
}
else /* white space */
optarg = nargv[optind];
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010814085203.2D2AC37B408>
