Skip site navigation (1)Skip section navigation (2)
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

This is a multipart MIME message.

--==_Exmh_9717437520
Content-Type: text/plain


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>

--==_Exmh_9717437520
Content-Type: text/plain ; name="getopt-patch"
Content-Description: getopt-patch
Content-Disposition: attachment; filename="getopt-patch"

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];

--==_Exmh_9717437520--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010814085203.2D2AC37B408>