Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

gnushit

Name: Anonymous 2009-10-30 14:03

#include <unistd.h>
int main(int argc, char *argv[])
{
    return execl("/bin/true", NULL);
}

This makes GNU true segfault in a call to strrchr().

Name: Anonymous 2009-10-31 1:52

>>13
"Should", yes, technically speaking:
Early proposals required that the value of argc  passed  to  main()  be
"one  or greater". This was driven by the same requirement in drafts of
the ISO C standard. In fact, historical implementations have  passed  a
value  of zero when no arguments are supplied to the caller of the exec
functions.  This requirement was removed from the  ISO C  standard  and
subsequently  removed from this volume of IEEE Std 1003.1-2001 as well.
The wording, in particular the use  of  the  word  should,  requires  a
Strictly  Conforming POSIX Application to pass at least one argument to
the exec function, thus guaranteeing that argc be one or  greater  when
invoked  by  such an application. In fact, this is good practice, since
many existing applications reference argv[0] without first checking the
value of argc.

However, there's nothing disallowing argv[0] from being NULL; and in any event, there's really no reason why true ought to be poking at argv-anything.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List