[PATCH] Sanitize printf functions

Kostya Serebryany kcc at google.com
Fri Dec 27 01:54:05 PST 2013



================
Comment at: asan/asan_intercepted_functions.h:79
@@ -78,1 +78,3 @@
 
+#if SANITIZER_INTERCEPT_SCANF
+# define ASAN_INTERCEPT_PRINTF 1
----------------
Yury Gribov wrote:
> Kostya Serebryany wrote:
> > Why scanf? 
> I felt cynical and simply grabbed SANITIZER_INTERCEPT_SCANF from sanitizer_common/sanitizer_platform_interceptors.h in hope that printf and scanf always go together. What about renaming SANITIZER_INTERCEPT_SCANF to SANITIZER_INTERCEPT_FORMAT?
I would have a separate SANITIZER_INTERCEPT_PRINTF

================
Comment at: asan/asan_interceptors.cc:678
@@ +677,3 @@
+#if ASAN_INTERCEPT_PRINTF
+// TODO(ygribov): move to sanitizer_common_interceptors.inc
+// to reuse in e.g. other sanitizers?
----------------
Yury Gribov wrote:
> Kostya Serebryany wrote:
> > yes, please
> I tried this initially but realized that Msan already intercepts printf stuff. What's the general policy about what goes into sanitizer_common (e.g. strcmp) and what gets re-implemented in each sanitizer (e.g. memset)?
msan interceptors are rudimentary and will have to be replaced with these *eventually*.
Here is a suggestion: move the code to sanitizer_common_interceptors.inc
but define  SANITIZER_INTERCEPT_PRINTF to 1 only in asan.
tsan and msan will follow later.


http://llvm-reviews.chandlerc.com/D2480



More information about the llvm-commits mailing list