[PATCH skalibs] Fix envalloc_merge

From: Josiah Frentsos <jfrent_at_tilde.team>
Date: Thu, 19 Oct 2023 13:01:43 -0400

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_at_tilde.team>
---
 src/libenvexec/envalloc_merge.c | 5 +++--
 1 file 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
_at__at_ -7,9 +7,10 _at__at_
 
 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 ;
 }
-- 
2.42.0
Received on Thu Oct 19 2023 - 19:01:43 CEST

This archive was generated by hypermail 2.4.0 : Thu Oct 19 2023 - 19:07:27 CEST