[PATCH] D64773: [ASan] Support `{f}puts(NULL)` on Darwin

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 12:55:25 PDT 2019


delcypher added inline comments.


================
Comment at: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc:1244
   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);
----------------
@yln 

There are a few things I would have done differently here

* Add a comment explaining why we do this on mac.  Just referencing the man page is probably fine.
* put `COMMON_INTERCEPTOR_READ_RANGE(...)` in curly braces. Because `COMMON_INTERCEPTOR_READ_RANGE` is a macro this feels like a disaster waiting to happen because the macro could expand into to multiple statements with the end result being that only the first statement gets guarded. I looked at how `COMMON_INTERCEPTOR_READ_RANGE` is implement and it's fine in this case because it uses (after several macro expansions) `do {...} while (false)` idiom. 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64773/new/

https://reviews.llvm.org/D64773





More information about the llvm-commits mailing list