[msan] Fix wordexp after D108646

I introduced this bug reformating the patch before commit.
This commit is contained in:
Vitaly Buka 2021-08-24 16:23:50 -07:00
parent 2ed8053d46
commit 629411d799
2 changed files with 3 additions and 1 deletions

View File

@ -3758,6 +3758,7 @@ TEST(MemorySanitizer, wordexp) {
ASSERT_STREQ("a", w.we_wordv[0]);
ASSERT_STREQ("b", w.we_wordv[1]);
ASSERT_STREQ("c", w.we_wordv[2]);
EXPECT_POISONED(w.we_wordv[3]);
}
TEST(MemorySanitizer, wordexp_initial_offset) {
@ -3770,6 +3771,7 @@ TEST(MemorySanitizer, wordexp_initial_offset) {
ASSERT_STREQ("a", w.we_wordv[1]);
ASSERT_STREQ("b", w.we_wordv[2]);
ASSERT_STREQ("c", w.we_wordv[3]);
EXPECT_POISONED(w.we_wordv[4]);
}
template<class T>

View File

@ -3997,7 +3997,7 @@ INTERCEPTOR(int, wordexp, char *s, __sanitizer_wordexp_t *p, int flags) {
if (!res && p) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p, sizeof(*p));
uptr we_wordc =
((flags & wordexp_wrde_dooffs) ? p->we_wordc : 0) + p->we_wordc;
((flags & wordexp_wrde_dooffs) ? p->we_offs : 0) + p->we_wordc;
if (we_wordc)
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p->we_wordv,
sizeof(*p->we_wordv) * we_wordc);