X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmisc%2Fwordexp.c;h=15adddbe381e14cb6e70b7db6f6502e84111deb6;hb=94167cafd5a8f4f8309c3f82f5bda17f4767cb60;hp=4a3efc7bc40a83d055bb1f4d952e6b70b2d4893c;hpb=6250c0be4b56ca42b8b4db1d2b9d672811378dc0;p=musl diff --git a/src/misc/wordexp.c b/src/misc/wordexp.c index 4a3efc7b..15adddbe 100644 --- a/src/misc/wordexp.c +++ b/src/misc/wordexp.c @@ -82,6 +82,8 @@ static int do_wordexp(const char *s, wordexp_t *we, int flags) if (we->we_offs > SIZE_MAX/sizeof(void *)/4) return WRDE_NOSPACE; i += we->we_offs; + } else { + we->we_offs = 0; } if (pipe(p) < 0) return WRDE_NOSPACE; @@ -137,6 +139,10 @@ static int do_wordexp(const char *s, wordexp_t *we, int flags) we->we_wordv = wv; we->we_wordc = i; + + for (i=we->we_offs; i; i--) + we->we_wordv[i-1] = 0; + if (flags & WRDE_DOOFFS) we->we_wordc -= we->we_offs; return err; }