From: Tom Hughes Date: Tue, 23 Aug 2011 10:11:02 +0000 (+0000) Subject: Make a copy of any environment string we are going to modify when X-Git-Tag: svn/VALGRIND_3_7_0~236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e5fe809d0a50084492e2f67bb852769c78d9b72;p=thirdparty%2Fvalgrind.git Make a copy of any environment string we are going to modify when 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 --- diff --git a/coregrind/m_libcproc.c b/coregrind/m_libcproc.c index b24ce25a52..df65d104ad 100644 --- a/coregrind/m_libcproc.c +++ b/coregrind/m_libcproc.c @@ -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_*.