Introduce custom wrappers for sprintf & snprintf to propagate the labels of the arguments to the output string.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Note that internal_vsnprintf does not implement the full spec of vsnprintf
Looks like a naming conflict -- the code does end up calling the libc vsnprintf. I've asked for the name to be changed to avoid this confusion.
lib/dfsan/dfsan_custom.cc | ||
---|---|---|
878 ↗ | (On Diff #14282) | It is confusing to give this function the same name as an existing function in sanitizer_common. |
909 ↗ | (On Diff #14282) | Likewise, this should probably have a different name. |
1101 ↗ | (On Diff #14282) | This can just be va_arg(ap, dfsan_label *) as pointer types are not affected by default argument promotion. |
test/dfsan/custom.c | ||
777 ↗ | (On Diff #14282) | Please add a test for each occurrence of the PRINTF macro in the implementation. |
lib/dfsan/dfsan_custom.cc | ||
---|---|---|
916 ↗ | (On Diff #14325) | Can you use InternalMmapVector here? |
test/dfsan/custom.c | ||
806 ↗ | (On Diff #14325) | 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? |
lib/dfsan/dfsan_custom.cc | ||
---|---|---|
916 ↗ | (On Diff #14325) | Done. |
test/dfsan/custom.c | ||
806 ↗ | (On Diff #14325) | 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? |
test/dfsan/custom.c | ||
---|---|---|
806 ↗ | (On Diff #14325) | Ok. Now each string is formatted twice, with and without a labelled argument. |
lib/dfsan/dfsan_custom.cc | ||
---|---|---|
912 ↗ | (On Diff #14459) | InternalMmapVector<Chunk> should be simpler? |
lib/dfsan/dfsan_custom.cc | ||
---|---|---|
912 ↗ | (On Diff #14459) | Done |