[compiler-rt] r175424 - [Sanitizer] Make temporary filename depend on user ID
Alexey Samsonov
samsonov at google.com
Sun Feb 17 23:17:12 PST 2013
Author: samsonov
Date: Mon Feb 18 01:17:12 2013
New Revision: 175424
URL: http://llvm.org/viewvc/llvm-project?rev=175424&view=rev
Log:
[Sanitizer] Make temporary filename depend on user ID
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=175424&r1=175423&r2=175424&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Mon Feb 18 01:17:12 2013
@@ -126,6 +126,7 @@ void DumpProcessMap();
bool FileExists(const char *filename);
const char *GetEnv(const char *name);
const char *GetPwd();
+u32 GetUid();
void ReExec();
bool StackSizeIsUnlimited();
void SetStackSizeLimitInBytes(uptr limit);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc?rev=175424&r1=175423&r2=175424&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Mon Feb 18 01:17:12 2013
@@ -44,6 +44,10 @@ int GetPid() {
return getpid();
}
+u32 GetUid() {
+ return getuid();
+}
+
uptr GetThreadSelf() {
return (uptr)pthread_self();
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=175424&r1=175423&r2=175424&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Mon Feb 18 01:17:12 2013
@@ -131,6 +131,10 @@ const char *GetPwd() {
UNIMPLEMENTED();
}
+u32 GetUid() {
+ UNIMPLEMENTED();
+}
+
void DumpProcessMap() {
UNIMPLEMENTED();
}
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cc?rev=175424&r1=175423&r2=175424&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_libc_test.cc Mon Feb 18 01:17:12 2013
@@ -55,22 +55,24 @@ TEST(SanitizerCommon, FileOps) {
const char *str2 = "zxcv";
uptr len2 = internal_strlen(str2);
- const char kTempFileName[] = "/tmp/sanitizer_common.tmp";
- fd_t fd = OpenFile(kTempFileName, true);
+ u32 uid = GetUid();
+ char temp_filename[128];
+ internal_snprintf(temp_filename, 128, "/tmp/sanitizer_common.tmp.%d", uid);
+ fd_t fd = OpenFile(temp_filename, true);
EXPECT_NE(fd, kInvalidFd);
EXPECT_EQ(len1, internal_write(fd, str1, len1));
EXPECT_EQ(len2, internal_write(fd, str2, len2));
internal_close(fd);
- fd = OpenFile(kTempFileName, false);
+ fd = OpenFile(temp_filename, false);
EXPECT_NE(fd, kInvalidFd);
uptr fsize = internal_filesize(fd);
EXPECT_EQ(len1 + len2, fsize);
#if SANITIZER_TEST_HAS_STAT_H
struct stat st1, st2, st3;
- EXPECT_EQ(0, internal_stat(kTempFileName, &st1));
- EXPECT_EQ(0, internal_lstat(kTempFileName, &st2));
+ EXPECT_EQ(0, internal_stat(temp_filename, &st1));
+ EXPECT_EQ(0, internal_lstat(temp_filename, &st2));
EXPECT_EQ(0, internal_fstat(fd, &st3));
EXPECT_EQ(fsize, (uptr)st3.st_size);
#endif
More information about the llvm-commits
mailing list