[PATCH] Custom wrappers for DFSanitizing sprintf & snprintf

Lorenzo Martignoni martignlo at google.com
Thu Oct 2 07:10:35 PDT 2014


================
Comment at: lib/dfsan/dfsan_custom.cc:878
@@ +877,3 @@
+// input.
+static int internal_snprintf(char *str, size_t off, bool has_size, size_t size,
+                             const char *format, size_t format_size, ...) {
----------------
pcc wrote:
> It is confusing to give this function the same name as an existing function in `sanitizer_common`.
I realize the name was not optimal but I did not realize the collision. Renamed.

================
Comment at: lib/dfsan/dfsan_custom.cc:909
@@ +908,3 @@
+// propagate labels more precisely.
+static int internal_vsnprintf(char *str, bool has_size, size_t size,
+                              const char *format, va_list ap) {
----------------
pcc wrote:
> Likewise, this should probably have a different name.
Done

================
Comment at: lib/dfsan/dfsan_custom.cc:1101
@@ +1100,3 @@
+
+  dfsan_label *ret_label_ptr = (dfsan_label *) va_arg(ap, dfsan_label_va *);
+  *ret_label_ptr = 0;
----------------
pcc wrote:
> This can just be `va_arg(ap, dfsan_label *)` as pointer types are not affected by default argument promotion.
Done

================
Comment at: test/dfsan/custom.c:777
@@ -776,1 +776,3 @@
 
+void test_sprintf() {
+  char buf[2048];
----------------
pcc wrote:
> Please add a test for each occurrence of the `PRINTF` macro in the implementation.
Done

http://reviews.llvm.org/D5561






More information about the llvm-commits mailing list