diff options
author | Vitaly Buka <vitalybuka@google.com> | 2017-06-07 01:53:38 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2017-06-07 01:53:38 +0000 |
commit | 35f212efc287a7b582afcb41d86bdff7a29e7367 (patch) | |
tree | e8b427e5d37de5664d3054b77858e49e793962e7 /lib/sanitizer_common/sanitizer_common_interceptors.inc | |
parent | b36ffc36dc75bbb701525be82ebe47e8879d1d45 (diff) |
[tsan]: Fix GNU version of strerror_r interceptor
GNU version of strerror_r returns a result pointer that doesn't match the input
buffer. The result pointer is in fact a pointer to some internal storage.
TSAN was recording a write to this location, which was incorrect.
Fixed https://github.com/google/sanitizers/issues/696
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_common_interceptors.inc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_common_interceptors.inc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc index c0c08a031..6ca431d8a 100644 --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -3395,7 +3395,10 @@ INTERCEPTOR(char *, strerror_r, int errnum, char *buf, SIZE_T buflen) { // its metadata. See // https://github.com/google/sanitizers/issues/321. char *res = REAL(strerror_r)(errnum, buf, buflen); - COMMON_INTERCEPTOR_WRITE_RANGE(ctx, res, REAL(strlen)(res) + 1); + if (res == buf) + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, res, REAL(strlen)(res) + 1); + else + COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, REAL(strlen)(res) + 1); return res; } #endif //(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE || |