From fd7dc9d1d7311b05e92464de1fc4eab6f2407b51 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 11 Jul 2019 17:57:27 +0000 Subject: bugfix: memcmp doesn't guarantee not touching bytes after cmp fails. --- src/libstddjb/env_merge.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/libstddjb/env_merge.c') diff --git a/src/libstddjb/env_merge.c b/src/libstddjb/env_merge.c index f7ba335..9129cf3 100644 --- a/src/libstddjb/env_merge.c +++ b/src/libstddjb/env_merge.c @@ -16,8 +16,7 @@ size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t e { size_t split = str_chr(modifs + i, '=') ; size_t j = 0 ; - for (; j < vlen ; j++) - if (!memcmp(modifs + i, v[j], split) && (v[j][split] == '=')) break ; + for (; j < vlen ; j++) if (!strncmp(modifs + i, v[j], split+1)) break ; if (j < vlen) v[j] = v[--vlen] ; if (modifs[i + split]) v[vlen++] = modifs + i ; } -- cgit v1.2.3