1*90b4d1bcSRoy Sundahl // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2*90b4d1bcSRoy Sundahl // See https://llvm.org/LICENSE.txt for license information. 3*90b4d1bcSRoy Sundahl // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4*90b4d1bcSRoy Sundahl 5*90b4d1bcSRoy Sundahl #include <cstddef> 6*90b4d1bcSRoy Sundahl #include <cstdint> 7*90b4d1bcSRoy Sundahl #include <cstdio> 8*90b4d1bcSRoy Sundahl #include <cstdlib> 9*90b4d1bcSRoy Sundahl #include <cstring> 10*90b4d1bcSRoy Sundahl 11*90b4d1bcSRoy Sundahl #include "FuzzerIO.h" 12*90b4d1bcSRoy Sundahl LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)13*90b4d1bcSRoy Sundahlextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 14*90b4d1bcSRoy Sundahl const char *FileName = "big-file.txt"; 15*90b4d1bcSRoy Sundahl FILE *f = fopen(FileName, "w"); 16*90b4d1bcSRoy Sundahl 17*90b4d1bcSRoy Sundahl // This is the biggest file possible unless CopyFileToErr() uses Puts() 18*90b4d1bcSRoy Sundahl fprintf(f, "%2147483646s", "2Gb-2"); 19*90b4d1bcSRoy Sundahl 20*90b4d1bcSRoy Sundahl // This makes the file too big if CopyFileToErr() uses fprintf("%s", <file>) 21*90b4d1bcSRoy Sundahl fprintf(f, "THIS LINE RESPONSIBLE FOR EXCEEDING 2Gb FILE SIZE\n"); 22*90b4d1bcSRoy Sundahl fclose(f); 23*90b4d1bcSRoy Sundahl 24*90b4d1bcSRoy Sundahl // Should now because CopyFileToErr() now uses Puts() 25*90b4d1bcSRoy Sundahl fuzzer::CopyFileToErr(FileName); 26*90b4d1bcSRoy Sundahl 27*90b4d1bcSRoy Sundahl // File is >2Gb so clean up 28*90b4d1bcSRoy Sundahl remove(FileName); 29*90b4d1bcSRoy Sundahl 30*90b4d1bcSRoy Sundahl return 0; 31*90b4d1bcSRoy Sundahl } 32