[compiler-rt] 629411d - [msan] Fix wordexp after D108646

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 24 16:36:38 PDT 2021


Author: Vitaly Buka
Date: 2021-08-24T16:36:28-07:00
New Revision: 629411d799223d7bc7aad98661b1443a4788c0c5

URL: https://github.com/llvm/llvm-project/commit/629411d799223d7bc7aad98661b1443a4788c0c5
DIFF: https://github.com/llvm/llvm-project/commit/629411d799223d7bc7aad98661b1443a4788c0c5.diff

LOG: [msan] Fix wordexp after D108646

I introduced this bug reformating the patch before commit.

Added: 
    

Modified: 
    compiler-rt/lib/msan/tests/msan_test.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/msan/tests/msan_test.cpp b/compiler-rt/lib/msan/tests/msan_test.cpp
index 7c9af6591787c..3ddba8c885c92 100644
--- a/compiler-rt/lib/msan/tests/msan_test.cpp
+++ b/compiler-rt/lib/msan/tests/msan_test.cpp
@@ -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>

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index e67fca8057aa7..d967c1d936ee7 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -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);


        


More information about the llvm-commits mailing list