[compiler-rt] r174970 - [msan] Allow zero buf pointer in getcwd() interceptor.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Tue Feb 12 06:36:22 PST 2013


Author: eugenis
Date: Tue Feb 12 08:36:22 2013
New Revision: 174970

URL: http://llvm.org/viewvc/llvm-project?rev=174970&view=rev
Log:
[msan] Allow zero buf pointer in getcwd() interceptor.

Modified:
    compiler-rt/trunk/lib/msan/msan_interceptors.cc
    compiler-rt/trunk/lib/msan/tests/msan_test.cc

Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=174970&r1=174969&r2=174970&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Tue Feb 12 08:36:22 2013
@@ -543,7 +543,7 @@ INTERCEPTOR(char *, getcwd, char *buf, S
   ENSURE_MSAN_INITED();
   char *res = REAL(getcwd)(buf, size);
   if (res)
-    __msan_unpoison(buf, REAL(strlen)(buf) + 1);
+    __msan_unpoison(res, REAL(strlen)(res) + 1);
   return res;
 }
 

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=174970&r1=174969&r2=174970&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Tue Feb 12 08:36:22 2013
@@ -605,6 +605,13 @@ TEST(MemorySanitizer, getcwd) {
   EXPECT_NOT_POISONED(path[0]);
 }
 
+TEST(MemorySanitizer, getcwd_gnu) {
+  char* res = getcwd(NULL, 0);
+  assert(res);
+  EXPECT_NOT_POISONED(res[0]);
+  free(res);
+}
+
 TEST(MemorySanitizer, realpath) {
   const char* relpath = ".";
   char path[PATH_MAX + 1];





More information about the llvm-commits mailing list