From 5e5fe809d0a50084492e2f67bb852769c78d9b72 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 23 Aug 2011 10:11:02 +0000 Subject: [PATCH] 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 --- coregrind/m_libcproc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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_*. -- 2.47.2