[fuzzer] Use puts() rather than printf() in CopyFileToErr()
authorRoy Sundahl <rsundahl@apple.com>
Thu, 16 Mar 2023 01:56:11 +0000 (18:56 -0700)
committerRoy Sundahl <rsundahl@apple.com>
Tue, 28 Mar 2023 21:19:35 +0000 (14:19 -0700)
commit90b4d1bcb20180c591385131b12fa90d2e4860b1
tree4bf2fc62e1f40ffb2fa4d0d6599022cf3458924c
parent2fe49ea0d07d503aedd0872bf0a66724552d4dcf
[fuzzer] Use puts() rather than printf() in CopyFileToErr()

CopyFileToErr() uses Printf("%s", ...) which fails with a negative size on
files >2Gb (Its path is through var-args wrappers to an unnecessary "%s"
expansion and subject to int overflows) Using puts() in place of printf()
bypasses this path and writes the string directly to stderr. This avoids the
present loss of data when a crashed worker has generated >2Gb of output.

rdar://99384640

Reviewed By: yln, rsundahl

Differential Revision: https://reviews.llvm.org/D146189
compiler-rt/lib/fuzzer/FuzzerIO.cpp
compiler-rt/lib/fuzzer/FuzzerIO.h
compiler-rt/test/fuzzer/BigFileCopy.cpp [new file with mode: 0644]
compiler-rt/test/fuzzer/big-file-copy.test [new file with mode: 0644]