From owner-freebsd-bugs@FreeBSD.ORG Fri Mar 12 02:50:22 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 99B0B16A4CE for ; Fri, 12 Mar 2004 02:50:22 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 68CFE43D45 for ; Fri, 12 Mar 2004 02:50:22 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i2CAoMbv040592 for ; Fri, 12 Mar 2004 02:50:22 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i2CAoMxO040591; Fri, 12 Mar 2004 02:50:22 -0800 (PST) (envelope-from gnats) Date: Fri, 12 Mar 2004 02:50:22 -0800 (PST) Message-Id: <200403121050.i2CAoMxO040591@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Ruslan Ermilov 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: Ruslan Ermilov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2004 10:50:22 -0000 The following reply was made to PR bin/64150; it has been noted by GNATS. From: Ruslan Ermilov To: Morten Rodal 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 12:49:14 +0200 On Fri, Mar 12, 2004 at 10:22:00AM +0100, Morten Rodal wrote: > > >Number: 64150 > >Category: bin > >Synopsis: [PATCH] ls(1) coredumps when started via execve(2) with no argv. > >Confidential: no > >Severity: non-critical > >Priority: low > >Responsible: freebsd-bugs > >State: open > >Quarter: > >Keywords: > >Date-Required: > >Class: sw-bug > >Submitter-Id: current-users > >Arrival-Date: Fri Mar 12 01:30:23 PST 2004 > >Closed-Date: > >Last-Modified: > >Originator: Morten Rodal > >Release: FreeBSD 5.2-CURRENT i386 > >Organization: > >Environment: > System: FreeBSD stud326.idi.ntnu.no 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Mon Mar 1 02:38:57 CET 2004 root@stud326.idi.ntnu.no:/usr/obj/usr/src/sys/stud326 i386 > > > >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). Cheers, -- Ruslan Ermilov FreeBSD committer ru@FreeBSD.org