Bug 498557 - execve() with NULL parameters causes segmentation fault
Summary: execve() with NULL parameters causes segmentation fault
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-05-01 04:55 UTC by Tetsuo Handa
Modified: 2009-05-01 07:07 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-05-01 06:44:13 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Tetsuo Handa 2009-05-01 04:55:29 UTC
Description of problem:
execve() with NULL parameters causes segmentation fault.

Version-Release number of selected component (if applicable):
kernel 2.6.29.1-111.fc11.i686.PAE
glibc-2.9.90-22.i686

How reproducible:
100%

Steps to Reproduce:
1. Compile below program and run.
-----
#include <unistd.h>
int main(int argc, char *argv[])
{
	execve("/bin/true", NULL, NULL);
	return 0;
}
-----
  
Actual results:
Segmentation fault happens.

Expected results:
Prints nothing.

Additional info:

Comment 1 Jakub Jelinek 2009-05-01 06:44:13 UTC
1) this is obviously invalid, POSIX says that both the argv and envp arguments
   to execve are arrays of character pointers, NULL is not an array of character 
   pointers
2) the crash is in /bin/true, not in glibc:
(gdb) bt
#0  0x00007ffff7af12ea in strrchr () from /lib64/libc.so.6
#1  0x00000000004012fe in set_program_name (argv0=0x0) at progname.c:44
#2  0x0000000000401233 in main (argc=0, argv=0xffffffff) at true.c:58
set_program_name is a coreutils function and obviously calling strrchr with NULL
argument segfaults.

Comment 2 Tetsuo Handa 2009-05-01 07:07:44 UTC
Oh, I didn't know execve() does not accept NULL parameters.
I thought NULL is acceptable because do_execve() (in kenrel) checks for NULL
parameters.
Thank you.


Note You need to log in before you can comment on or make changes to this bug.