-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Bruno Haible on 12/5/2009 6:08 AM: > Ad 2): > This is indeed a kernel problem: OpenBSD 4.0 returns with error code > EFAULT if you pass NULL to execve or execv or execvp. Linux 2.6.25.20 > does not. Here's the draft for a report to a linux-kernel mailing list. > Can someone please complete it for me? I am not used any more to rebuild > and install modified Linux kernels.
I haven't built a modified Linux kernel, either, but your proposed report looks decent from a first reading. > > Ad 3): > If you really want to do something that eases finding of such a bug in the > parent process, then - rather than sweeping the bug under the carpet - provide > an error message, like this. > > *** lib/progname.c.orig 2009-12-05 14:07:04.000000000 +0100 > --- lib/progname.c 2009-12-05 13:55:35.000000000 +0100 > *************** > *** 23,28 **** > --- 23,30 ---- > #include "progname.h" > > #include <errno.h> /* get program_invocation_name declaration */ > + #include <stdio.h> > + #include <stdlib.h> > #include <string.h> > > > *************** > *** 44,49 **** > --- 46,60 ---- > const char *slash; > const char *base; > > + /* Sanity check. POSIX requires the invoking process to pass a non-NULL > + argv[0]. */ > + if (argv0 == NULL) > + { > + fputs ("A NULL argv[0] was passed through the exec system call.\n", > + stderr); > + abort (); > + } This seems like a reasonable compromise to me, but I'll let Jim chime in. It avoids the segfault, while being verbose enough to let the user know where the real problem lies rather than papering over the problem by letting the program proceed. However, is the string worth marking as translatable? Or should it try error() rather than fputs()? (Although that gets a bit problematic, since error() relies on program_name, which we have just determined can't be set because argv[0] is NULL.) - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAksa2NQACgkQ84KuGfSFAYCSUwCgrk4iW36Cf5PuaLmK4DwL3hYD 2eUAn3/XUwabRx4Hgf/LRnYpdLmt5LxF =pwbT -----END PGP SIGNATURE-----