summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosiah Frentsos via skaware <skaware@list.skarnet.org>2023-10-19 13:01:43 -0400
committerLaurent Bercot <ska-skaware@skarnet.org>2023-10-28 13:15:55 +0000
commit83ff0ca30e725c25b8b7e6d78ff17246caf29cf8 (patch)
treeed5f505237d9f30ba0dbb1b554417089b032ae6f
parentd452fcefe0220893ef1a8f868640809b4766480c (diff)
downloadskalibs-83ff0ca30e725c25b8b7e6d78ff17246caf29cf8.tar.xz
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 <jfrent@tilde.team>
-rw-r--r--src/libenvexec/envalloc_merge.c5
1 files changed, 3 insertions, 2 deletions
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 ;
}