From owner-freebsd-bugs Wed Jan 9 16:20:12 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 6211437B41D for ; Wed, 9 Jan 2002 16:20:05 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g0A0K5W41473; Wed, 9 Jan 2002 16:20:05 -0800 (PST) (envelope-from gnats) Date: Wed, 9 Jan 2002 16:20:05 -0800 (PST) Message-Id: <200201100020.g0A0K5W41473@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Garrett Wollman Subject: Re: kern/33738: [PATCH] empty argv Reply-To: Garrett Wollman Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/33738; it has been noted by GNATS. From: Garrett Wollman To: Marc Olzheim Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: kern/33738: [PATCH] empty argv Date: Wed, 9 Jan 2002 19:11:33 -0500 (EST) < said: > Perhaps this should be caught as well in execve(2). One could also argue > that setuid programmers should expect the unexpected, but why not make > it easier on them... The POSIX specification is clear: calling execve() with zero arguments must be permitted (but no Strictly Conforming Application may do so), and programs must expect to be called without arguments. The Rationale states this explicitly: # Early proposals required that the value of argc passed to main( ) be # ``one or greater''. This was driven by the same requirement in # drafts of the ISO C standard. In fact, historical implementations # have passed a value of zero when no arguments are supplied to the # caller of the exec functions. This requirement was removed from the # ISO C standard and subsequently removed from this volume of IEEE Std # 1003.1-200x as well. The wording, in particular the use of the word # should, requires a Strictly Conforming POSIX Application to pass at # least one argument to the exec function, thus guaranteeing that argc # be one or greater when invoked by such an application. In fact, this # is good practice, since many existing applications reference argv[0] # without first checking the value of argc. (XSHd7, p. 758) If the Standard does not say that a list must be non-empty, then it may be empty. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message