brintos

brintos / llvm-project-archived public Read only

0
0
Text · 849 B · 853f7ba Raw
25 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// Test that fuzzer we can reload artifacts with any bytes inside.6#include <algorithm>7#include <cstdint>8#include <cstdlib>9#include <numeric>10#include <set>11 12extern "C" size_t LLVMFuzzerCustomMutator(uint8_t *Data, size_t Size,13                                          size_t MaxSize, unsigned int Seed) {14  std::srand(Seed);15  std::generate(Data, Data + MaxSize, std::rand);16  return MaxSize;17}18 19extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {20  if (Size > 5000 && std::set<uint8_t>(Data, Data + Size).size() > 255 &&21      (uint8_t)std::accumulate(Data, Data + Size, uint8_t(Size)) == 0)22    abort();23  return 0;24}25