]>
Commit | Line | Data |
---|---|---|
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> | |
12 | #include <openssl/opensslconf.h> | |
13 | #include "fuzzer.h" | |
14 | ||
15 | #ifndef OPENSSL_NO_FUZZ_LIBFUZZER | |
16 | ||
17 | int LLVMFuzzerInitialize(int *argc, char ***argv) | |
18 | { | |
19 | if (FuzzerInitialize) | |
20 | return FuzzerInitialize(argc, argv); | |
21 | return 0; | |
22 | } | |
23 | ||
24 | int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) { | |
25 | return FuzzerTestOneInput(buf, len); | |
26 | } | |
27 | ||
28 | #elif !defined(OPENSSL_NO_FUZZ_AFL) | |
29 | ||
30 | #define BUF_SIZE 65536 | |
31 | ||
32 | int main(int argc, char** argv) | |
33 | { | |
34 | if (FuzzerInitialize) | |
35 | FuzzerInitialize(&argc, &argv); | |
36 | ||
37 | while (__AFL_LOOP(10000)) { | |
38 | uint8_t *buf = malloc(BUF_SIZE); | |
39 | size_t size = read(0, buf, BUF_SIZE); | |
40 | ||
41 | FuzzerTestOneInput(buf, size); | |
42 | free(buf); | |
43 | } | |
44 | return 0; | |
45 | } | |
46 | ||
47 | #else | |
48 | ||
49 | #error "Unsupported fuzzer" | |
50 | ||
51 | #endif |