]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Don't try and validate the contents of the environment passed to
authorTom Hughes <tom@compton.nu>
Sat, 19 Jun 2004 13:02:34 +0000 (13:02 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 19 Jun 2004 13:02:34 +0000 (13:02 +0000)
the execve system call if the envp pointer is null as it causes
valgrind to die with a segmentation fault.

CCMAIL: 83573-done@bugs.kde.org

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2427

coregrind/vg_syscalls.c
none/tests/Makefile.am
none/tests/execve.c [new file with mode: 0644]
none/tests/execve.stderr.exp [new file with mode: 0644]
none/tests/execve.stdout.exp [new file with mode: 0644]
none/tests/execve.vgtest [new file with mode: 0644]

index d9d07beb0ee6d351c05c58f92dc9e153669fa231..bfd81b531a8ce6eedebfc6f255cb54bc5918bec9 100644 (file)
@@ -1838,7 +1838,8 @@ PRE(execve)
 
    SYSCALL_TRACK( pre_mem_read_asciiz, tid, "execve(filename)", arg1 );
    pre_argv_envp( arg2, tid, "execve(argv)", "execve(argv[i])" );
-   pre_argv_envp( arg3, tid, "execve(envp)", "execve(envp[i])" );
+   if (arg3 != (UInt)NULL)
+      pre_argv_envp( arg3, tid, "execve(envp)", "execve(envp[i])" );
 
    /* Erk.  If the exec fails, then the following will have made a
       mess of things which makes it hard for us to continue.  The
index abe57bd3bfadc5f29bb963c01a60bc5ffc2c6076..97ecf66984ccdde3ee965c6227a3d8957077b1b4 100644 (file)
@@ -27,6 +27,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        discard.stderr.exp discard.stdout.exp \
        discard.vgtest \
        exec-sigmask.vgtest exec-sigmask.stdout.exp exec-sigmask.stderr.exp \
+       execve.vgtext execve.stdout.exp execve.stderr.exp \
        floored.stderr.exp floored.stdout.exp \
        floored.vgtest \
        fork.stderr.exp fork.stdout.exp fork.vgtest \
@@ -66,8 +67,8 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
 
 check_PROGRAMS = \
        args badseg bitfield1 bt_everything bt_literal closeall coolo_strlen \
-       cpuid dastest discard exec-sigmask floored fork fpu_lazy_eflags \
-       fucomip $(INSN_TESTS) \
+       cpuid dastest discard exec-sigmask execve floored fork \
+       fpu_lazy_eflags fucomip $(INSN_TESTS) \
        int munmap_exe map_unmap mremap rcl_assert \
        rcrl readline1 resolv seg_override sem semlimit sha1_test \
        shortpush shorts smc1 susphello pth_blockedsig pushpopseg \
@@ -89,6 +90,7 @@ coolo_strlen_SOURCES  = coolo_strlen.c
 dastest_SOURCES        = dastest_c.c dastest_s.s
 discard_SOURCES        = discard.c
 exec_sigmask_SOURCES   = exec-sigmask.c
+execve                 = execve.c
 fork_SOURCES           = fork.c
 floored_SOURCES        = floored.c
 floored_LDADD          = -lm
diff --git a/none/tests/execve.c b/none/tests/execve.c
new file mode 100644 (file)
index 0000000..69b2c9f
--- /dev/null
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+   if (argc == 1)
+   {
+      char *newargv[3] = { argv[0], "done", NULL };
+     
+      if (execve(argv[0], newargv, NULL) < 0)
+      {
+         perror("execve");
+         exit(1);
+      }
+   }
+   
+   exit(0);
+}
diff --git a/none/tests/execve.stderr.exp b/none/tests/execve.stderr.exp
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/none/tests/execve.stdout.exp b/none/tests/execve.stdout.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/execve.vgtest b/none/tests/execve.vgtest
new file mode 100644 (file)
index 0000000..f67ce70
--- /dev/null
@@ -0,0 +1 @@
+prog: execve