From owner-freebsd-bugs@FreeBSD.ORG Fri Mar 12 03:00:31 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D6C6016A4CE for ; Fri, 12 Mar 2004 03:00:31 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id C64AB43D1F for ; Fri, 12 Mar 2004 03:00:31 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i2CB0Vbv040864 for ; Fri, 12 Mar 2004 03:00:31 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i2CB0VwH040863; Fri, 12 Mar 2004 03:00:31 -0800 (PST) (envelope-from gnats) Date: Fri, 12 Mar 2004 03:00:31 -0800 (PST) Message-Id: <200403121100.i2CB0VwH040863@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Morten Rodal Subject: Re: bin/64150: [PATCH] ls(1) coredumps when started via execve(2) with no argv. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Morten Rodal List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2004 11:00:32 -0000 The following reply was made to PR bin/64150; it has been noted by GNATS. From: Morten Rodal To: Ruslan Ermilov Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: bin/64150: [PATCH] ls(1) coredumps when started via execve(2) with no argv. Date: Fri, 12 Mar 2004 11:57:30 +0100 On Fri, Mar 12, 2004 at 12:49:14PM +0200, Ruslan Ermilov wrote: > On Fri, Mar 12, 2004 at 10:22:00AM +0100, Morten Rodal wrote: > > >Description: > > ls(1) calls the fts(3) functions for traversing a file hierarchy. > > If ls(1) is executed via execve(2) system call with a NULL argv > > and envp it will make the fts(3) functions core dump with a > > SIGBUS. > > > > If execve(2) is executed with a NULL (I am not sure this is > > legal?) argv, the executed program will have an argc value of -1. > > > > >How-To-Repeat: > > #include > > #include > > > > int main(int argc, char **argv) { > > execve("/bin/ls", NULL, NULL); > > > > return (1); > > } > > The execve(2) manpage says: > > : The argument argv is a pointer to a null-terminated array of character > : pointers to null-terminated character strings. These strings construct > : the argument list to be made available to the new process. At least one > : argument must be present in the array; by custom, the first element > : should be the name of the executed program (for example, the last compo- > : nent of path). > > Indeed you are correct, but I would have wished that execve(2) could set argc = 0 and not -1 for the newly created process. However I think this is a standards issue and I'll just correct this program to include argv and envp vectors when calling execve(2). Thanks for the quick response. -- Morten Rodal