From 83ff0ca30e725c25b8b7e6d78ff17246caf29cf8 Mon Sep 17 00:00:00 2001 From: Josiah Frentsos via skaware Date: Thu, 19 Oct 2023 13:01:43 -0400 Subject: Fix envalloc_merge Currently, envalloc_merge incorrectly passes the total number of environment entries to env_mergen as the number of modifs. Signed-off-by: Josiah Frentsos --- src/libenvexec/envalloc_merge.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/libenvexec') diff --git a/src/libenvexec/envalloc_merge.c b/src/libenvexec/envalloc_merge.c index 84716e4..2c6ea0e 100644 --- a/src/libenvexec/envalloc_merge.c +++ b/src/libenvexec/envalloc_merge.c @@ -7,9 +7,10 @@ int envalloc_merge (genalloc *v, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) { - size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ; + size_t modifn = byte_count(modifs, modiflen, '\0') ; + size_t n = envlen + 1 + modifn ; if (!genalloc_readyplus(char const *, v, n)) return 0 ; - n = env_mergen(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen, n) ; + n = env_mergen(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen, modifn) ; genalloc_setlen(char const *, v, genalloc_len(char const *, v) + n) ; return 1 ; } -- cgit v1.2.3