brintos

brintos / llvm-project-archived public Read only

0
0
Text · 903 B · 5515365 Raw
32 lines · cpp
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-exception4 5#include <cstddef>6#include <cstdint>7#include <cstdio>8#include <cstdlib>9#include <cstring>10 11#include "FuzzerIO.h"12 13extern "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 up28  remove(FileName);29 30  return 0;31}32