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: FileName, modes: "w" ); |
16 | |
17 | // This is the biggest file possible unless CopyFileToErr() uses Puts() |
18 | fprintf(stream: f, format: "%2147483646s" , "2Gb-2" ); |
19 | |
20 | // This makes the file too big if CopyFileToErr() uses fprintf("%s", <file>) |
21 | fprintf(stream: f, format: "THIS LINE RESPONSIBLE FOR EXCEEDING 2Gb FILE SIZE\n" ); |
22 | fclose(stream: f); |
23 | |
24 | // Should now because CopyFileToErr() now uses Puts() |
25 | fuzzer::CopyFileToErr(Path: FileName); |
26 | |
27 | // File is >2Gb so clean up |
28 | remove(filename: FileName); |
29 | |
30 | return 0; |
31 | } |
32 | |