From slaven.rezic@berlin.de  Sat Aug 11 07:07:56 2001
Return-Path: <slaven.rezic@berlin.de>
Received: from mailoutvl21.berlin.de (mail.berlin.de [195.243.105.33])
	by hub.freebsd.org (Postfix) with ESMTP id A9F2337B403
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 11 Aug 2001 07:07:55 -0700 (PDT)
	(envelope-from slaven.rezic@berlin.de)
Received: from herceg.de ([213.6.5.47]) by mailoutvl21.berlin.de
          (InterMail vK.4.03.04.00 201-232-130 license c0e4b842f1eddc5308d584e55543c802)
          with ESMTP id <20010811140833.NCFB25691.mailoutvl21@herceg.de>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Sat, 11 Aug 2001 16:08:33 +0200
Received: (from eserte@localhost)
	by vran.herceg.de (8.11.4/8.9.3) id f7BD8KV05536;
	Sat, 11 Aug 2001 15:08:20 +0200 (CEST)
	(envelope-from eserte)
Message-Id: <200108111308.f7BD8KV05536@vran.herceg.de>
Date: Sat, 11 Aug 2001 15:08:20 +0200 (CEST)
From: Slaven Rezic <eserte@vran.herceg.de>
Reply-To: Slaven Rezic <slaven.rezic@berlin.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: limits -d etc. should not output warning
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         29625
>Category:       bin
>Synopsis:       limits -d etc. should not output warning
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jkoshy
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 11 07:10:01 PDT 2001
>Closed-Date:    Wed Aug 15 20:30:55 PDT 2001
>Last-Modified:  Wed Aug 15 20:32:43 PDT 2001
>Originator:     Slaven Rezic
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
Private FreeBSD site, Berlin, Germany
>Environment:
System: FreeBSD vran.herceg.de 4.3-STABLE FreeBSD 4.3-STABLE #6: Mon Jul 9 11:49:47 CEST 2001 root@vran.herceg.de:/vran/home/src/FreeBSD-4/src/sys/compile/VRAN i386

	shell is tcsh
	
>Description:
	If I type

		limits -d

	I get a warning and the correct result:

	limits: option requires an argument -- d
	Resource limits (current):
	  datasize           524288 kb

	The warning should not be there. Same with other options (-c etc.).
	
>How-To-Repeat:
	See above

>Fix:
	I'm not sure whether the functionality (option takes
	optionally an argument) can be achieved with getopt(3).
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jkoshy 
Responsible-Changed-By: jkoshy 
Responsible-Changed-When: Tue Aug 14 00:56:43 PDT 2001 
Responsible-Changed-Why:  
I'll take care of this. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=29625 

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
Date: Tue, 14 Aug 2001 01:52:03 -0700 (PDT)

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

From: Mike Heffner <mheffner@novacoxmail.com>
To: (Joseph Koshy) <jkoshy@FreeBSD.ORG>
Cc: freebsd-audit@FreeBSD.ORG, freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/29625: limits -d etc. should not output warning
Date: Wed, 15 Aug 2001 17:26:28 -0400 (EDT)

 This message is in MIME format
 --_=XFMail.1.5.0.FreeBSD:20010815162830:291=_
 Content-Type: text/plain; charset=us-ascii
 
 
 On 14-Aug-2001 Joseph Koshy wrote:
 | 
 | 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?
 
 Looks good. Is this to be an MFC candidate?
 
 Mike
 
 -- 
   Mike Heffner         <mheffner@[acm.]vt.edu>
   Fredericksburg, VA       <mikeh@FreeBSD.org>
 
 
 --_=XFMail.1.5.0.FreeBSD:20010815162830:291=_
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQE7etttFokZQs3sv5kRAubUAJ9J2HHhfvoEcOOmir2BYWDBYgbKjACdG/CY
 gjSAJ7F5ZEzON6cmSIAulm4=
 =yfPD
 -----END PGP SIGNATURE-----
 
 --_=XFMail.1.5.0.FreeBSD:20010815162830:291=_--
 End of MIME message
State-Changed-From-To: open->closed 
State-Changed-By: jkoshy 
State-Changed-When: Wed Aug 15 20:30:55 PDT 2001 
State-Changed-Why:  
Fixed in rev 1.4 of "src/lib/libc/stdlib/getopt.c". 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=29625 
>Unformatted:
