]>
Commit | Line | Data |
---|---|---|
f59d0131 | 1 | /* |
1212818e | 2 | * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. |
f59d0131 | 3 | * |
0642931f | 4 | * Licensed under the Apache License 2.0 (the "License"); |
f59d0131 KR |
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 | ||
63c5ac80 PS |
18 | int LLVMFuzzerInitialize(int *argc, char ***argv); |
19 | int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len); | |
20 | ||
f59d0131 KR |
21 | int LLVMFuzzerInitialize(int *argc, char ***argv) |
22 | { | |
baae2cbc | 23 | return FuzzerInitialize(argc, argv); |
f59d0131 KR |
24 | } |
25 | ||
f3e911d5 KR |
26 | int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) |
27 | { | |
f59d0131 KR |
28 | return FuzzerTestOneInput(buf, len); |
29 | } | |
30 | ||
31 | #elif !defined(OPENSSL_NO_FUZZ_AFL) | |
32 | ||
33 | #define BUF_SIZE 65536 | |
34 | ||
35 | int main(int argc, char** argv) | |
36 | { | |
baae2cbc | 37 | FuzzerInitialize(&argc, &argv); |
f59d0131 KR |
38 | |
39 | while (__AFL_LOOP(10000)) { | |
40 | uint8_t *buf = malloc(BUF_SIZE); | |
41 | size_t size = read(0, buf, BUF_SIZE); | |
42 | ||
43 | FuzzerTestOneInput(buf, size); | |
44 | free(buf); | |
45 | } | |
ad4da7fb KR |
46 | |
47 | FuzzerCleanup(); | |
f59d0131 KR |
48 | return 0; |
49 | } | |
50 | ||
51 | #else | |
52 | ||
53 | #error "Unsupported fuzzer" | |
54 | ||
55 | #endif |