[compiler-rt] r187789 - [sanitizer] Fix NULL arg handling in setitimer/getitimer interceptors.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Tue Aug 6 02:54:33 PDT 2013
Author: eugenis
Date: Tue Aug 6 04:54:33 2013
New Revision: 187789
URL: http://llvm.org/viewvc/llvm-project?rev=187789&view=rev
Log:
[sanitizer] Fix NULL arg handling in setitimer/getitimer interceptors.
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=187789&r1=187788&r2=187789&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Tue Aug 6 04:54:33 2013
@@ -1397,6 +1397,13 @@ TEST(MemorySanitizer, getitimer) {
assert(!res);
}
+TEST(MemorySanitizer, setitimer_null) {
+ setitimer(ITIMER_VIRTUAL, 0, 0);
+ // Not testing the return value, since it the behaviour seems to differ
+ // between libc implementations and POSIX.
+ // Should never crash, though.
+}
+
TEST(MemorySanitizer, time) {
time_t t;
EXPECT_POISONED(t);
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=187789&r1=187788&r2=187789&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Tue Aug 6 04:54:33 2013
@@ -758,7 +758,7 @@ INTERCEPTOR(int, getitimer, int which, v
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, getitimer, which, curr_value);
int res = REAL(getitimer)(which, curr_value);
- if (!res) {
+ if (!res && curr_value) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, curr_value, struct_itimerval_sz);
}
return res;
@@ -766,7 +766,8 @@ INTERCEPTOR(int, getitimer, int which, v
INTERCEPTOR(int, setitimer, int which, const void *new_value, void *old_value) {
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, setitimer, which, new_value, old_value);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, new_value, struct_itimerval_sz);
+ if (new_value)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, new_value, struct_itimerval_sz);
int res = REAL(setitimer)(which, new_value, old_value);
if (!res && old_value) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, old_value, struct_itimerval_sz);
More information about the llvm-commits
mailing list