[msan] Intercept tzset.

llvm-svn: 190682
This commit is contained in:
Evgeniy Stepanov 2013-09-13 11:27:38 +00:00
parent 7681afdff0
commit 9be91e970e
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,16 @@
// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
#include <stdlib.h>
#include <string.h>
#include <time.h>
extern char *tzname[2];
int main(void) {
if (!strlen(tzname[0]) || !strlen(tzname[1]))
exit(1);
tzset();
if (!strlen(tzname[0]) || !strlen(tzname[1]))
exit(1);
return 0;
}

View File

@ -1071,6 +1071,18 @@ INTERCEPTOR(int, pthread_join, void *th, void **retval) {
return res;
}
extern char *tzname[2];
INTERCEPTOR(void, tzset) {
ENSURE_MSAN_INITED();
REAL(tzset)();
if (tzname[0])
__msan_unpoison(tzname[0], REAL(strlen)(tzname[0]) + 1);
if (tzname[1])
__msan_unpoison(tzname[1], REAL(strlen)(tzname[1]) + 1);
return;
}
struct MSanInterceptorContext {
bool in_interceptor_scope;
};
@ -1323,6 +1335,7 @@ void InitializeInterceptors() {
INTERCEPT_FUNCTION(pthread_create);
INTERCEPT_FUNCTION(pthread_key_create);
INTERCEPT_FUNCTION(pthread_join);
INTERCEPT_FUNCTION(tzset);
inited = 1;
}
} // namespace __msan