File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ std::string FileToString(const std::string &Path) {
65
65
}
66
66
67
67
void CopyFileToErr (const std::string &Path) {
68
- Printf ( " %s " , FileToString (Path).c_str ());
68
+ Puts ( FileToString (Path).c_str ());
69
69
}
70
70
71
71
void WriteToFile (const Unit &U, const std::string &Path) {
@@ -151,6 +151,11 @@ void CloseStdout() {
151
151
DiscardOutput (1 );
152
152
}
153
153
154
+ void Puts (const char *Str) {
155
+ fputs (Str, OutputFile);
156
+ fflush (OutputFile);
157
+ }
158
+
154
159
void Printf (const char *Fmt, ...) {
155
160
va_list ap;
156
161
va_start (ap, Fmt);
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ void CloseStdout();
58
58
FILE *GetOutputFile ();
59
59
void SetOutputFile (FILE *NewOutputFile);
60
60
61
+ void Puts (const char *Str);
61
62
void Printf (const char *Fmt, ...);
62
63
void VPrintf (bool Verbose, const char *Fmt, ...);
63
64
Original file line number Diff line number Diff line change
1
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2
+ // See https://llvm.org/LICENSE.txt for license information.
3
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
+
5
+ #include < cstddef>
6
+ #include < cstdint>
7
+ #include < cstdio>
8
+ #include < cstdlib>
9
+ #include < cstring>
10
+
11
+ #include " FuzzerIO.h"
12
+
13
+ extern " C" int LLVMFuzzerTestOneInput (const uint8_t *Data, size_t Size) {
14
+ const char *FileName = " big-file.txt" ;
15
+ FILE *f = fopen (FileName, " w" );
16
+
17
+ // This is the biggest file possible unless CopyFileToErr() uses Puts()
18
+ fprintf (f, " %2147483646s" , " 2Gb-2" );
19
+
20
+ // This makes the file too big if CopyFileToErr() uses fprintf("%s", <file>)
21
+ fprintf (f, " THIS LINE RESPONSIBLE FOR EXCEEDING 2Gb FILE SIZE\n " );
22
+ fclose (f);
23
+
24
+ // Should now because CopyFileToErr() now uses Puts()
25
+ fuzzer::CopyFileToErr (FileName);
26
+
27
+ // File is >2Gb so clean up
28
+ remove (FileName);
29
+
30
+ return 0 ;
31
+ }
Original file line number Diff line number Diff line change
1
+ REQUIRES: darwin
2
+ UNSUPPORTED: ios
3
+ RUN: %cpp_compiler %S/BigFileCopy.cpp -o %t
4
+ RUN: %run %t -runs=1 -rss_limit_mb=4096 2>big-file-out.txt; result=$?
5
+ RUN: %run rm -f big-file.txt big-file-out.txt
6
+ RUN: (exit $result)
You can’t perform that action at this time.
0 commit comments