[compiler-rt] r201410 - [sanitizer] Fix getpwuid_r (and similar) interceptors missing one of the arguments.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Feb 14 04:32:15 PST 2014


Author: eugenis
Date: Fri Feb 14 06:32:15 2014
New Revision: 201410

URL: http://llvm.org/viewvc/llvm-project?rev=201410&view=rev
Log:
[sanitizer] Fix getpwuid_r (and similar) interceptors missing one of the arguments.

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

Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=201410&r1=201409&r2=201410&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Fri Feb 14 06:32:15 2014
@@ -3006,6 +3006,20 @@ TEST(MemorySanitizer, getpwuid) {
   ASSERT_EQ(p->pw_uid, 0);
 }
 
+TEST(MemorySanitizer, getpwuid_r) {
+  struct passwd pwd;
+  struct passwd *pwdres;
+  char buf[10000];
+  int res = getpwuid_r(0, &pwd, buf, sizeof(buf), &pwdres);
+  ASSERT_EQ(0, res);
+  EXPECT_NOT_POISONED(pwd.pw_name);
+  ASSERT_TRUE(pwd.pw_name != NULL);
+  EXPECT_NOT_POISONED(pwd.pw_name[0]);
+  EXPECT_NOT_POISONED(pwd.pw_uid);
+  ASSERT_EQ(pwd.pw_uid, 0);
+  EXPECT_NOT_POISONED(pwdres);
+}
+
 TEST(MemorySanitizer, getpwnam_r) {
   struct passwd pwd;
   struct passwd *pwdres;
@@ -3017,6 +3031,7 @@ TEST(MemorySanitizer, getpwnam_r) {
   EXPECT_NOT_POISONED(pwd.pw_name[0]);
   EXPECT_NOT_POISONED(pwd.pw_uid);
   ASSERT_EQ(pwd.pw_uid, 0);
+  EXPECT_NOT_POISONED(pwdres);
 }
 
 TEST(MemorySanitizer, getpwnam_r_positive) {
@@ -3040,6 +3055,7 @@ TEST(MemorySanitizer, getgrnam_r) {
   ASSERT_TRUE(grp.gr_name != NULL);
   EXPECT_NOT_POISONED(grp.gr_name[0]);
   EXPECT_NOT_POISONED(grp.gr_gid);
+  EXPECT_NOT_POISONED(grpres);
 }
 
 TEST(MemorySanitizer, getgroups) {

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=201410&r1=201409&r2=201410&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Fri Feb 14 06:32:15 2014
@@ -917,6 +917,7 @@ INTERCEPTOR(int, getpwnam_r, const char
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, pwd, struct_passwd_sz);
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, buflen);
   }
+  if (result) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result, sizeof(*result));
   return res;
 }
 INTERCEPTOR(int, getpwuid_r, u32 uid, void *pwd, char *buf, SIZE_T buflen,
@@ -928,6 +929,7 @@ INTERCEPTOR(int, getpwuid_r, u32 uid, vo
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, pwd, struct_passwd_sz);
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, buflen);
   }
+  if (result) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result, sizeof(*result));
   return res;
 }
 INTERCEPTOR(int, getgrnam_r, const char *name, void *grp, char *buf,
@@ -940,6 +942,7 @@ INTERCEPTOR(int, getgrnam_r, const char
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, grp, struct_group_sz);
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, buflen);
   }
+  if (result) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result, sizeof(*result));
   return res;
 }
 INTERCEPTOR(int, getgrgid_r, u32 gid, void *grp, char *buf, SIZE_T buflen,
@@ -951,6 +954,7 @@ INTERCEPTOR(int, getgrgid_r, u32 gid, vo
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, grp, struct_group_sz);
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, buflen);
   }
+  if (result) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, result, sizeof(*result));
   return res;
 }
 #define INIT_GETPWNAM_R_AND_FRIENDS      \





More information about the llvm-commits mailing list