This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/11056] New: missing warning when execvp is passed a NULL pointer


When a program is invoked through the exec* functions, according to POSIX,
argv[0] must be non-NULL. This follows from
  <http://www.opengroup.org/onlinepubs/9699919799/functions/exec.html>
which says
  "The value in argv[0] should point to a filename that is associated with
   the process being started"
and from
  <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html>
sections 3.170 and 3.367.

glibc does not warn about incorrect values of argv[0].

Attached program yields currently no warnings:
$ gcc -O -Wall caller.c

With the proposed patch to unistd.h, gcc gives warnings for 7 out of 11
problematic cases. Not perfect, but better than nothing.

Btw, the reason for the warnings is that it yields to undefined behaviour:
either random error messages like here:

$ ./a.out 1 /bin/rm
: missing operand
Try `(null) --help' for more information.
$ ./a.out 2 /bin/rm
: missing operand
Try `(null) --help' for more information.
$ ./a.out 3 /bin/rm
fexecve failed: Invalid argument
$ ./a.out 4 /bin/rm
fexecve failed: Invalid argument
$ ./a.out 5 /bin/rm
: missing operand
Try `(null) --help' for more information.
$ ./a.out 6 /bin/rm
: missing operand
Try `(null) --help' for more information.
$ ./a.out 7 /bin/rm
: missing operand
Try `(null) --help' for more information.
$ ./a.out 8 /bin/rm
: missing operand
Try `(null) --help' for more information.
$ ./a.out 9 /bin/rm
: missing operand
Try `(null) --help' for more information.
$ ./a.out 10 /bin/rm
: missing operand
Try `(null) --help' for more information.
$ ./a.out 11 /bin/rm
: missing operand
Try `(null) --help' for more information.

or core dumps:

$ ./a.out 1 /usr/bin/msgcat
Segmentation fault

-- 
           Summary: missing warning when execvp is passed a NULL pointer
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: bruno at clisp dot org
                CC: glibc-bugs at sources dot redhat dot com,jim at meyering
                    dot net
 GCC build triplet: i586-suse-linux
  GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=11056

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]