summaryrefslogtreecommitdiff
path: root/src/misc/wordexp.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-06-25 18:54:33 -0400
committerRich Felker <dalias@aerifal.cx>2011-06-25 18:54:33 -0400
commit6250c0be4b56ca42b8b4db1d2b9d672811378dc0 (patch)
tree6648d99dffd0633e9fca57e31b3048b1b872bce1 /src/misc/wordexp.c
parentfebbd12d00883a716a9edca25011f8aa306b859b (diff)
downloadmusl-6250c0be4b56ca42b8b4db1d2b9d672811378dc0.tar.gz
wordexp cannot use we_offs unless WRDE_DOOFFS flag is set
previously, a potentially-indeterminate value from we_offs was being used, resulting in wrong we_wordc and subsequent crashes in the caller.
Diffstat (limited to 'src/misc/wordexp.c')
-rw-r--r--src/misc/wordexp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/misc/wordexp.c b/src/misc/wordexp.c
index 4609b99f..4a3efc7b 100644
--- a/src/misc/wordexp.c
+++ b/src/misc/wordexp.c
@@ -136,7 +136,8 @@ static int do_wordexp(const char *s, wordexp_t *we, int flags)
}
we->we_wordv = wv;
- we->we_wordc = i - we->we_offs;
+ we->we_wordc = i;
+ if (flags & WRDE_DOOFFS) we->we_wordc -= we->we_offs;
return err;
}