From cb66b4d4fd29fdc460e871f16955ab7a895cd321 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 27 Feb 2022 00:46:40 +0000 Subject: Fix envdir_noclamp Signed-off-by: Laurent Bercot --- src/libenvexec/envdir_noclamp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libenvexec/envdir_noclamp.c b/src/libenvexec/envdir_noclamp.c index b87291a..0741c9d 100644 --- a/src/libenvexec/envdir_noclamp.c +++ b/src/libenvexec/envdir_noclamp.c @@ -64,12 +64,12 @@ int envdir_internal_noclamp (char const *path, stralloc *modifs, unsigned int op { if (errno != EPIPE) goto errfd ; if (!(options & SKALIBS_ENVDIR_NOCHOMP)) modifs->len = pos ; - if (!stralloc_catb(modifs, "\n", 1)) goto errfd ; + modifs->len++ ; } if (!r) modifs->len = pos - 1 ; else { - size_t i = pos ; + modifs->len-- ; if (!(options & SKALIBS_ENVDIR_NOCHOMP)) { while (modifs->len-- > pos) @@ -78,11 +78,11 @@ int envdir_internal_noclamp (char const *path, stralloc *modifs, unsigned int op if ((c != ' ') && (c != '\t') && (c != '\r')) break ; } modifs->len++ ; - for (; i < modifs->len ; i++) if (!modifs->s[i]) modifs->s[i] = nullis ; } } } fd_close(fd) ; + for (; pos < modifs->len ; pos++) if (!modifs->s[pos]) modifs->s[pos] = nullis ; if (!stralloc_0(modifs)) goto err ; n++ ; } -- cgit v1.2.3