summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-10-14 11:52:40 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-10-14 11:52:40 +0000
commit3f4beff5efdd0d30844ca8b270876f7d59a608e7 (patch)
tree828cd976cfa03bd045e243b026623d2ca5cf8f4b
parentd9def29fe0dc8fc70ef270dcc1a266ad9257ec1f (diff)
downloadcompiler-rt-3f4beff5efdd0d30844ca8b270876f7d59a608e7.tar.gz
compiler-rt-3f4beff5efdd0d30844ca8b270876f7d59a608e7.tar.bz2
compiler-rt-3f4beff5efdd0d30844ca8b270876f7d59a608e7.tar.xz
[msan] Intercept strto(d|f|ld)_l and glibc-specific __strto(d|f|ld)_l.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192583 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/msan/msan_interceptors.cc66
-rw-r--r--lib/msan/tests/msan_test.cc11
2 files changed, 77 insertions, 0 deletions
diff --git a/lib/msan/msan_interceptors.cc b/lib/msan/msan_interceptors.cc
index b616b984..ec1de679 100644
--- a/lib/msan/msan_interceptors.cc
+++ b/lib/msan/msan_interceptors.cc
@@ -329,6 +329,26 @@ INTERCEPTOR(double, strtod, const char *nptr, char **endptr) { // NOLINT
return res;
}
+INTERCEPTOR(double, strtod_l, const char *nptr, char **endptr,
+ void *loc) { // NOLINT
+ ENSURE_MSAN_INITED();
+ double res = REAL(strtod_l)(nptr, endptr, loc); // NOLINT
+ if (!__msan_has_dynamic_component()) {
+ __msan_unpoison(endptr, sizeof(*endptr));
+ }
+ return res;
+}
+
+INTERCEPTOR(double, __strtod_l, const char *nptr, char **endptr,
+ void *loc) { // NOLINT
+ ENSURE_MSAN_INITED();
+ double res = REAL(__strtod_l)(nptr, endptr, loc); // NOLINT
+ if (!__msan_has_dynamic_component()) {
+ __msan_unpoison(endptr, sizeof(*endptr));
+ }
+ return res;
+}
+
INTERCEPTOR(float, strtof, const char *nptr, char **endptr) { // NOLINT
ENSURE_MSAN_INITED();
float res = REAL(strtof)(nptr, endptr); // NOLINT
@@ -338,6 +358,26 @@ INTERCEPTOR(float, strtof, const char *nptr, char **endptr) { // NOLINT
return res;
}
+INTERCEPTOR(float, strtof_l, const char *nptr, char **endptr,
+ void *loc) { // NOLINT
+ ENSURE_MSAN_INITED();
+ float res = REAL(strtof_l)(nptr, endptr, loc); // NOLINT
+ if (!__msan_has_dynamic_component()) {
+ __msan_unpoison(endptr, sizeof(*endptr));
+ }
+ return res;
+}
+
+INTERCEPTOR(float, __strtof_l, const char *nptr, char **endptr,
+ void *loc) { // NOLINT
+ ENSURE_MSAN_INITED();
+ float res = REAL(__strtof_l)(nptr, endptr, loc); // NOLINT
+ if (!__msan_has_dynamic_component()) {
+ __msan_unpoison(endptr, sizeof(*endptr));
+ }
+ return res;
+}
+
INTERCEPTOR(long double, strtold, const char *nptr, char **endptr) { // NOLINT
ENSURE_MSAN_INITED();
long double res = REAL(strtold)(nptr, endptr); // NOLINT
@@ -347,6 +387,26 @@ INTERCEPTOR(long double, strtold, const char *nptr, char **endptr) { // NOLINT
return res;
}
+INTERCEPTOR(long double, strtold_l, const char *nptr, char **endptr,
+ void *loc) { // NOLINT
+ ENSURE_MSAN_INITED();
+ long double res = REAL(strtold_l)(nptr, endptr, loc); // NOLINT
+ if (!__msan_has_dynamic_component()) {
+ __msan_unpoison(endptr, sizeof(*endptr));
+ }
+ return res;
+}
+
+INTERCEPTOR(long double, __strtold_l, const char *nptr, char **endptr,
+ void *loc) { // NOLINT
+ ENSURE_MSAN_INITED();
+ long double res = REAL(__strtold_l)(nptr, endptr, loc); // NOLINT
+ if (!__msan_has_dynamic_component()) {
+ __msan_unpoison(endptr, sizeof(*endptr));
+ }
+ return res;
+}
+
INTERCEPTOR(int, vasprintf, char **strp, const char *format, va_list ap) {
ENSURE_MSAN_INITED();
int res = REAL(vasprintf)(strp, format, ap);
@@ -1320,8 +1380,14 @@ void InitializeInterceptors() {
INTERCEPT_FUNCTION(strtoul);
INTERCEPT_FUNCTION(strtoull);
INTERCEPT_FUNCTION(strtod);
+ INTERCEPT_FUNCTION(strtod_l);
+ INTERCEPT_FUNCTION(__strtod_l);
INTERCEPT_FUNCTION(strtof);
+ INTERCEPT_FUNCTION(strtof_l);
+ INTERCEPT_FUNCTION(__strtof_l);
INTERCEPT_FUNCTION(strtold);
+ INTERCEPT_FUNCTION(strtold_l);
+ INTERCEPT_FUNCTION(__strtold_l);
INTERCEPT_FUNCTION(vasprintf);
INTERCEPT_FUNCTION(asprintf);
INTERCEPT_FUNCTION(vsprintf);
diff --git a/lib/msan/tests/msan_test.cc b/lib/msan/tests/msan_test.cc
index c28f79b4..0e89fce9 100644
--- a/lib/msan/tests/msan_test.cc
+++ b/lib/msan/tests/msan_test.cc
@@ -1269,6 +1269,17 @@ TEST(MemorySanitizer, strtod) {
EXPECT_NOT_POISONED((S8) e);
}
+#ifdef __GLIBC__
+extern "C" double __strtod_l(const char *nptr, char **endptr, locale_t loc);
+TEST(MemorySanitizer, __strtod_l) {
+ locale_t loc = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0);
+ char *e;
+ assert(0 != __strtod_l("1.5", &e, loc));
+ EXPECT_NOT_POISONED((S8) e);
+ freelocale(loc);
+}
+#endif // __GLIBC__
+
TEST(MemorySanitizer, strtof) {
char *e;
assert(0 != strtof("1.5", &e));