]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Avoid reading beyond the end of the environment variable when
authorTom Hughes <tom@compton.nu>
Tue, 15 Jun 2010 12:49:07 +0000 (12:49 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 15 Jun 2010 12:49:07 +0000 (12:49 +0000)
using mash_colon_env to remove paths. Should fix #215914.

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

coregrind/m_libcproc.c

index 2e181ebbcb4c2f3a975780670d63a51bc73c00f9..991b2d51857726cb480599201aefd95b996b9537 100644 (file)
@@ -182,9 +182,13 @@ static void mash_colon_env(Char *varp, const Char *remove_pattern)
            entry_start = output+1;     /* entry starts after ':' */
       }
 
-      *output++ = *varp++;
+      if (*varp)
+         *output++ = *varp++;
    }
 
+   /* make sure last entry is nul terminated */
+   *output = '\0';
+
    /* match against the last entry */
    if (VG_(string_match)(remove_pattern, entry_start)) {
       output = entry_start;