Page MenuHomePhabricator

[ASan] Support `{f}puts(NULL)` on Darwin
ClosedPublic

Authored by yln on Jul 15 2019, 2:49 PM.

Details

Summary

On Darwin, the man page states that "both fputs() and puts() print
`(null)' if str is NULL."

rdar://48227136

Diff Detail

Repository
rL LLVM

Event Timeline

yln created this revision.Jul 15 2019, 2:49 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 15 2019, 2:49 PM
Herald added subscribers: llvm-commits, Restricted Project, kubamracek. · View Herald Transcript
This revision is now accepted and ready to land.Jul 15 2019, 3:31 PM
This revision was automatically updated to reflect the committed changes.
delcypher added inline comments.Jul 18 2019, 12:54 PM
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
1244

@yln

There are a few things I would have done differently here

  • Add a comment explaining why we do this on mac. Just referencing the man page is probably fine.
  • put COMMON_INTERCEPTOR_READ_RANGE(...) in curly braces. Because COMMON_INTERCEPTOR_READ_RANGE is a macro this feels like a disaster waiting to happen because the macro could expand into to multiple statements with the end result being that only the first statement gets guarded. I looked at how COMMON_INTERCEPTOR_READ_RANGE is implement and it's fine in this case because it uses (after several macro expansions) do {...} while (false) idiom.
yln marked 2 inline comments as done.Jul 18 2019, 1:16 PM
yln added inline comments.
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
1244

Good points, thanks!
Updated in be7a7ae0c3da18138fa5f117765c56b5ee8df3c4.