diff options
Diffstat (limited to 'src/libenvexec')
-rw-r--r-- | src/libenvexec/env_mergen.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libenvexec/env_mergen.c b/src/libenvexec/env_mergen.c index acc7c39..64a77cb 100644 --- a/src/libenvexec/env_mergen.c +++ b/src/libenvexec/env_mergen.c @@ -10,7 +10,7 @@ size_t env_mergen (char const **v, size_t vmax, char const *const *envp, size_t { size_t vlen = envlen ; size_t i = 0 ; - if (envlen + n + 1 > vmax) return (errno = ENAMETOOLONG, 0) ; + if (envlen >= vmax) return 0 ; for (; i < envlen ; i++) v[i] = envp[i] ; for (i = 0 ; i < modiflen ; i += strlen(modifs + i) + 1) { @@ -19,8 +19,13 @@ size_t env_mergen (char const **v, size_t vmax, char const *const *envp, size_t for (; j < vlen ; j++) if (!strncmp(modifs + i, v[j], split) && (v[j][split] == '=')) break ; if (j < vlen) v[j] = v[--vlen] ; - if (modifs[i + split]) v[vlen++] = modifs + i ; + if (modifs[i + split]) + { + if (vlen >= vmax) return 0 ; + v[vlen++] = modifs + i ; + } } + if (vlen >= vmax) return 0 ; v[vlen++] = 0 ; return vlen ; } |