summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common_interceptors.inc
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-07-17 16:09:25 +0000
committerJulian Lettner <jlettner@apple.com>2019-07-17 16:09:25 +0000
commite12315901803f289670a6a0713c60ac9ad2056e5 (patch)
treea63bb73bb87cfce9ff75aa0b451e91e9cbbf2057 /lib/sanitizer_common/sanitizer_common_interceptors.inc
parent36ec38116f34385736fbae5591b1c31c76ad24bd (diff)
downloadcompiler-rt-e12315901803f289670a6a0713c60ac9ad2056e5.tar.gz
[ASan] Support `{f}puts(NULL)` on Darwin
On Darwin, the man page states that "both fputs() and puts() print `(null)' if str is NULL." rdar://48227136 Reviewed By: Lekensteyn Differential Revision: https://reviews.llvm.org/D64773 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@366342 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_common_interceptors.inc')
-rw-r--r--lib/sanitizer_common/sanitizer_common_interceptors.inc6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 5b68c0191..9f5a91ac9 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1241,7 +1241,8 @@ INTERCEPTOR_WITH_SUFFIX(int, fputs, char *s, void *file) {
// libc file streams can call user-supplied functions, see fopencookie.
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, fputs, s, file);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
+ if (!SANITIZER_MAC || s)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
return REAL(fputs)(s, file);
}
#define INIT_FPUTS COMMON_INTERCEPT_FUNCTION(fputs)
@@ -1254,7 +1255,8 @@ INTERCEPTOR(int, puts, char *s) {
// libc file streams can call user-supplied functions, see fopencookie.
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, puts, s);
- COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
+ if (!SANITIZER_MAC || s)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, s, REAL(strlen)(s) + 1);
return REAL(puts)(s);
}
#define INIT_PUTS COMMON_INTERCEPT_FUNCTION(puts)