diff options
| -rw-r--r-- | compiler-rt/lib/msan/lit_tests/tzset.cc | 16 | ||||
| -rw-r--r-- | compiler-rt/lib/msan/msan_interceptors.cc | 13 |
2 files changed, 29 insertions, 0 deletions
diff --git a/compiler-rt/lib/msan/lit_tests/tzset.cc b/compiler-rt/lib/msan/lit_tests/tzset.cc new file mode 100644 index 00000000000..7e1c2cfad56 --- /dev/null +++ b/compiler-rt/lib/msan/lit_tests/tzset.cc @@ -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; +} diff --git a/compiler-rt/lib/msan/msan_interceptors.cc b/compiler-rt/lib/msan/msan_interceptors.cc index 002c41c5b87..0431fed6cf5 100644 --- a/compiler-rt/lib/msan/msan_interceptors.cc +++ b/compiler-rt/lib/msan/msan_interceptors.cc @@ -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 |

