]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make a copy of any environment string we are going to modify when
authorTom Hughes <tom@compton.nu>
Tue, 23 Aug 2011 10:11:02 +0000 (10:11 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 23 Aug 2011 10:11:02 +0000 (10:11 +0000)
we are cleaning up the environment before an exec, otherwise we
will seg fault if the string is read only. Fixes #270326.

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

coregrind/m_libcproc.c

index b24ce25a522bcfe42552c3c4e1e9cb662556b283..df65d104ada0f92b1f8af3478d3e1dc40c6d1246 100644 (file)
@@ -241,14 +241,14 @@ void VG_(env_remove_valgrind_env_stuff)(Char** envp)
    // - DYLD_INSERT_LIBRARIES and DYLD_SHARED_REGION are Darwin-only
    for (i = 0; envp[i] != NULL; i++) {
       if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0)
-         ld_preload_str = &envp[i][11];
+         ld_preload_str = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.1", &envp[i][11]);
       if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=", 16) == 0)
-         ld_library_path_str = &envp[i][16];
+         ld_library_path_str = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.2", &envp[i][16]);
       if (VG_(strncmp)(envp[i], "DYLD_INSERT_LIBRARIES=", 22) == 0)
-         dyld_insert_libraries_str = &envp[i][22];
+         dyld_insert_libraries_str = VG_(arena_strdup)(VG_AR_CORE, "libcproc.erves.3", &envp[i][22]);
    }
 
-   buf = VG_(arena_malloc)(VG_AR_CORE, "libcproc.erves.1",
+   buf = VG_(arena_malloc)(VG_AR_CORE, "libcproc.erves.4",
                            VG_(strlen)(VG_(libdir)) + 20);
 
    // Remove Valgrind-specific entries from LD_*.