瀏覽代碼

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.
Rich Felker 14 年之前
父節點
當前提交
6250c0be4b
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/misc/wordexp.c

+ 2 - 1
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;
 }