From: Tom Hughes Date: Tue, 15 Jun 2010 12:49:07 +0000 (+0000) Subject: Avoid reading beyond the end of the environment variable when X-Git-Tag: svn/VALGRIND_3_6_0~263 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55aa9d747f6f654696f0e897ca73e7cbaaad3028;p=thirdparty%2Fvalgrind.git Avoid reading beyond the end of the environment variable when using mash_colon_env to remove paths. Should fix #215914. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11178 --- diff --git a/coregrind/m_libcproc.c b/coregrind/m_libcproc.c index 2e181ebbcb..991b2d5185 100644 --- a/coregrind/m_libcproc.c +++ b/coregrind/m_libcproc.c @@ -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;