35 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 <stdint.h>6#include <stdio.h>7#include <stdlib.h>8 9// Dummy functions used to avoid dependency on AFL.10extern "C" void __afl_manual_init() {}11 12extern "C" int __afl_persistent_loop(unsigned int N) {13 static int Count = N;14 fprintf(stderr, "__afl_persistent_loop called, Count = %d\n", Count);15 return Count--;16}17 18// This declaration exists to prevent the Darwin linker19// from complaining about this being a missing weak symbol.20extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {21 return 0;22}23 24extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {25 puts("STDOUT MESSAGE");26 fflush(stdout);27 fprintf(stderr, "STDERR MESSAGE\n"28 "LLVMFuzzerTestOneInput called; Size = %zd\n",29 Size);30 if (Size < 4)31 return 0;32 33 return Data[Size];34}35