[PATCH] Custom wrappers for DFSanitizing sprintf & snprintf

Lorenzo Martignoni martignlo at google.com
Mon Oct 6 08:41: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);
----------------
pcc wrote:
> Can you use `InternalMmapVector` here?
Done.

================
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));                       \
----------------
pcc wrote:
> 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?
I renamed the file to custom.cc so that we can use a template. Now the tests also labels the arguments and makes sure the labels are applied to the correct part of the output buffer. 

Do you think it is necessary to try the same passing a zero-label?

http://reviews.llvm.org/D5561






More information about the llvm-commits mailing list