Skip to content

Commit 629411d

Browse files
committed
[msan] Fix wordexp after D108646
I introduced this bug reformating the patch before commit.
1 parent 2ed8053 commit 629411d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

compiler-rt/lib/msan/tests/msan_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,6 +3758,7 @@ TEST(MemorySanitizer, wordexp) {
37583758
ASSERT_STREQ("a", w.we_wordv[0]);
37593759
ASSERT_STREQ("b", w.we_wordv[1]);
37603760
ASSERT_STREQ("c", w.we_wordv[2]);
3761+
EXPECT_POISONED(w.we_wordv[3]);
37613762
}
37623763

37633764
TEST(MemorySanitizer, wordexp_initial_offset) {
@@ -3770,6 +3771,7 @@ TEST(MemorySanitizer, wordexp_initial_offset) {
37703771
ASSERT_STREQ("a", w.we_wordv[1]);
37713772
ASSERT_STREQ("b", w.we_wordv[2]);
37723773
ASSERT_STREQ("c", w.we_wordv[3]);
3774+
EXPECT_POISONED(w.we_wordv[4]);
37733775
}
37743776

37753777
template<class T>

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3997,7 +3997,7 @@ INTERCEPTOR(int, wordexp, char *s, __sanitizer_wordexp_t *p, int flags) {
39973997
if (!res && p) {
39983998
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p, sizeof(*p));
39993999
uptr we_wordc =
4000-
((flags & wordexp_wrde_dooffs) ? p->we_wordc : 0) + p->we_wordc;
4000+
((flags & wordexp_wrde_dooffs) ? p->we_offs : 0) + p->we_wordc;
40014001
if (we_wordc)
40024002
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p->we_wordv,
40034003
sizeof(*p->we_wordv) * we_wordc);

0 commit comments

Comments
 (0)