From 289236dd5a7f05bd5253840fa03d358ca51406b0 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 20 Dec 2023 15:45:36 +0000 Subject: Fix small modifier string bug. Build with new skalibs to avoid env_merge() problems. Signed-off-by: Laurent Bercot --- src/tipideed/cgi.c | 1 + src/tipideed/tipideed.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tipideed/cgi.c b/src/tipideed/cgi.c index 14da139..a2554f5 100644 --- a/src/tipideed/cgi.c +++ b/src/tipideed/cgi.c @@ -381,6 +381,7 @@ int respond_cgi (tipidee_rql *rql, char const *docroot, char const *fn, size_t d char const *envp[envmax] ; modify_env(rql, docroot, hdr, bodylen, fn + docrootlen, infopath) ; env_merge(envp, envmax, (char const *const *)environ, g.envlen, g.sa.s + g.cwdlen + 1, g.sa.len - (g.cwdlen+1)) ; + g.sa.len = sabase ; return ra->flags & TIPIDEE_RA_FLAG_NPH ? do_nph(rql, docroot, argv, envp, body, bodylen) : diff --git a/src/tipideed/tipideed.c b/src/tipideed/tipideed.c index 69280f6..75a8195 100644 --- a/src/tipideed/tipideed.c +++ b/src/tipideed/tipideed.c @@ -125,8 +125,8 @@ static inline void prep_env (size_t *remoteip, size_t *remotehost) memcpy(var + protolen, "REMOTEHOST", 11) ; x = getenv(var) ; - if ((x && !stralloc_catb(&g.sa, var, protolen + 11)) - || !stralloc_catb(&g.sa, "REMOTE_HOST=", 12)) dienomem() ; + if (x && !stralloc_catb(&g.sa, var, protolen + 11)) dienomem() ; + if (!stralloc_catb(&g.sa, "REMOTE_HOST=", 12)) dienomem() ; *remotehost = g.sa.len ; if (x) { @@ -136,7 +136,7 @@ static inline void prep_env (size_t *remoteip, size_t *remotehost) { if (!stralloc_readyplus(&g.sa, m + 2)) dienomem() ; if (ip46_is6(&ip)) stralloc_catb(&g.sa, "[", 1) ; - stralloc_catb(&g.sa, g.sa.s + *remoteip, m) ; + stralloc_catb(&g.sa, g.sa.s + *remoteip, m-1) ; if (ip46_is6(&ip)) stralloc_catb(&g.sa, "]", 1) ; } if (!stralloc_0(&g.sa)) dienomem() ; -- cgit v1.2.3