[PATCH] D64773: [ASan] Support `{f}puts(NULL)` on Darwin
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 09:09:56 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366342: [ASan] Support `{f}puts(NULL)` on Darwin (authored by yln, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D64773?vs=209962&id=210346#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64773/new/
https://reviews.llvm.org/D64773
Files:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/fputs_puts_null.cc
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1241,7 +1241,8 @@
// 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 @@
// 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)
Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/fputs_puts_null.cc
===================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/fputs_puts_null.cc
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/fputs_puts_null.cc
@@ -0,0 +1,16 @@
+// On Darwin, the man page states that "both fputs() and puts() print `(null)'
+// if str is NULL."
+//
+// RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s
+// CHECK: {{^\(null\)---\(null\)$}}
+
+#include <assert.h>
+#include <stdio.h>
+
+int main(void) {
+ assert(fputs(NULL, stdout) >= 0);
+ fputs("---", stdout);
+ assert(puts(NULL) >= 0);
+
+ return 0;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64773.210346.patch
Type: text/x-patch
Size: 1793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190717/77137c58/attachment.bin>
More information about the llvm-commits
mailing list