Date: Fri, 12 Mar 2004 03:00:31 -0800 (PST) From: Morten Rodal <morten@rodal.no> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/64150: [PATCH] ls(1) coredumps when started via execve(2) with no argv. Message-ID: <200403121100.i2CB0VwH040863@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/64150; it has been noted by GNATS. From: Morten Rodal <morten@rodal.no> To: Ruslan Ermilov <ru@freebsd.org> 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 <stdio.h> > > #include <unistd.h> > > > > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403121100.i2CB0VwH040863>