[PATCH] Custom wrappers for DFSanitizing sprintf & snprintf

Peter Collingbourne peter at pcc.me.uk
Thu Oct 2 18:25:20 PDT 2014


================
Comment at: lib/dfsan/dfsan_custom.cc:916
@@ +915,3 @@
+  while (*format) {
+    chunks = (Chunk *)realloc(chunks, sizeof(Chunk) * ++num_chunks);
+    assert(chunks);
----------------
Can you use `InternalMmapVector` here?

================
Comment at: test/dfsan/custom.c:806
@@ +805,3 @@
+  // Test formatting of all supported types of format strings.
+#define ASSERT_SPRINTF(expected, fmt, arg) {             \
+    memset(buf, 'a', sizeof(buf));                       \
----------------
Please modify this macro to check labels (in both the unlabelled and labelled cases). You already have a test for %s above so you don't need to check it here.

Though I would much prefer if this could be done without macros. Maybe we can move these tests to a .cc file and use templates?

http://reviews.llvm.org/D5561






More information about the llvm-commits mailing list