]> git.ipfire.org Git - thirdparty/openssl.git/blame - fuzz/driver.c
bnrand_range: Always call bnrand() with the correct flag
[thirdparty/openssl.git] / fuzz / driver.c
CommitLineData
f59d0131
KR
1/*
2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL licenses, (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.openssl.org/source/license.html
8 * or in the file LICENSE in the source distribution.
9 */
10#include <stdint.h>
11#include <unistd.h>
0a320653 12#include <stdlib.h>
f59d0131
KR
13#include <openssl/opensslconf.h>
14#include "fuzzer.h"
15
16#ifndef OPENSSL_NO_FUZZ_LIBFUZZER
17
18int LLVMFuzzerInitialize(int *argc, char ***argv)
19{
baae2cbc 20 return FuzzerInitialize(argc, argv);
f59d0131
KR
21}
22
f3e911d5
KR
23int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
24{
f59d0131
KR
25 return FuzzerTestOneInput(buf, len);
26}
27
28#elif !defined(OPENSSL_NO_FUZZ_AFL)
29
30#define BUF_SIZE 65536
31
32int main(int argc, char** argv)
33{
baae2cbc 34 FuzzerInitialize(&argc, &argv);
f59d0131
KR
35
36 while (__AFL_LOOP(10000)) {
37 uint8_t *buf = malloc(BUF_SIZE);
38 size_t size = read(0, buf, BUF_SIZE);
39
40 FuzzerTestOneInput(buf, size);
41 free(buf);
42 }
ad4da7fb
KR
43
44 FuzzerCleanup();
f59d0131
KR
45 return 0;
46}
47
48#else
49
50#error "Unsupported fuzzer"
51
52#endif