Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's

Stefan Farfeleder stefan at fafoe.narf.at
Fri Jan 16 10:38:15 PST 2009


On Fri, Jan 16, 2009 at 10:33:15AM -0800, Nate Eldredge wrote:
> Pop quiz: which of the following statements is correct?
> 
> #include <stdlib.h>
> #include <unistd.h>
> 
> execl("/bin/sh", "/bin/sh", 0);
> execl("/bin/sh", "/bin/sh", NULL);

None, as NULL is allowed to expand to 0.  You have to write

execl("/bin/sh", "/bin/sh", (char *)0);


More information about the freebsd-hackers mailing list