Subject: Re: bin/2737: execle called with missing argument in shutdown
To: None <augustss@cs.chalmers.se>
From: der Mouse <mouse@Holo.Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 09/09/1996 06:36:49
> >Description:
> 		execle(_PATH_REBOOT, "reboot", "-l", "-n", 0);

> >Fix:
> 	Change the two (2) calls to look like this
> 		execle(_PATH_XXX, "xxx", "-l", "-n", 0, 0);

Neither of these calls is correct.  Since execle is a varargs function,
no argument type can be specified for either of the zeroes, even if a
prototype is in scope.  It should be

	execle(_PATH_xxx, "xxx", "-l", "-n", (char *)0, (char **)0);

(the manpage says those last two arguments should have assorted consts,
but the code for execle does not agree - the code should be fixed, but
until it is, the caller should agree with the called.)

And that's assuming a nil pointer is allowed for the environment
argument; as I read the manpage, it isn't ("This additional parameter
is an array of pointers to null-terminated strings and must be
terminated by a NULL pointer.") - it turns out that in the current
implementation, that argument gets passed unchanged to execve(), and
the kernel is tolerant of a nil pointer for the environment.

Of course, this is all language-lawyering.  If you're willing to assume
the current implementation, where integer zero is the same size and
representation as nil pointer on all ports (at least AFAIK - doesn't
NetBSD/alpha use 64 bit ints?), then sure, you can be sloppy.  I think
it's a bad idea to do so, though; it piles up trouble down the line,
when we want to support a machine for which that's not the case.

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     01 EE 31 F6 BB 0C 34 36  00 F3 7C 5A C1 A0 67 1D