blob: c7553f421fb97f6c8e30e6042ae300aebc53583f [file] [log] [blame]
Kostya Serebryanyf3424592015-05-22 22:35:31 +00001//===- FuzzerInterface.cpp - Mutate a test input --------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9// Parts of public interface for libFuzzer.
10//===----------------------------------------------------------------------===//
11
12
13#include "FuzzerInterface.h"
14#include "FuzzerInternal.h"
15
16namespace fuzzer {
Kostya Serebryany404c69f2015-07-24 01:06:40 +000017
18void FuzzerRandomLibc::ResetSeed(int seed) { srand(seed); }
19
20size_t FuzzerRandomLibc::Rand() { return rand(); }
21
22UserSuppliedFuzzer::UserSuppliedFuzzer()
23 : OwnRand(true), Rand(new FuzzerRandomLibc(0)) {}
24
25UserSuppliedFuzzer::UserSuppliedFuzzer(FuzzerRandomBase *Rand) : Rand(Rand) {}
26
27UserSuppliedFuzzer::~UserSuppliedFuzzer() {
28 if (OwnRand)
29 delete Rand;
30}
31
Kostya Serebryanyf3424592015-05-22 22:35:31 +000032size_t UserSuppliedFuzzer::BasicMutate(uint8_t *Data, size_t Size,
33 size_t MaxSize) {
Kostya Serebryany404c69f2015-07-24 01:06:40 +000034 return ::fuzzer::Mutate(Data, Size, MaxSize, *Rand);
Kostya Serebryanyf3424592015-05-22 22:35:31 +000035}
36size_t UserSuppliedFuzzer::BasicCrossOver(const uint8_t *Data1, size_t Size1,
37 const uint8_t *Data2, size_t Size2,
38 uint8_t *Out, size_t MaxOutSize) {
Kostya Serebryany404c69f2015-07-24 01:06:40 +000039 return ::fuzzer::CrossOver(Data1, Size1, Data2, Size2, Out, MaxOutSize,
40 *Rand);
Kostya Serebryanyf3424592015-05-22 22:35:31 +000041}
42
43} // namespace fuzzer.