Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdint.h> |
| 3 | #include <stdlib.h> |
| 4 | |
Juraj Vijtiuk | dba2881 | 2020-09-24 13:56:18 +0200 | [diff] [blame] | 5 | int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len); |
| 6 | |
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 7 | #ifdef __AFL_COMPILER |
| 8 | |
| 9 | int main(void) { |
| 10 | int ret; |
| 11 | uint8_t buf[64 * 1024]; |
| 12 | |
| 13 | #ifdef __AFL_LOOP |
| 14 | while (__AFL_LOOP(10000)) |
| 15 | #endif |
| 16 | { |
| 17 | ret = fread(buf, 1, sizeof(buf), stdin); |
| 18 | if (ret < 0) { |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | LLVMFuzzerTestOneInput(buf, ret); |
| 23 | |
| 24 | } |
| 25 | |
| 26 | return 0; |
| 27 | } |
| 28 | |
Juraj Vijtiuk | c496e6f | 2020-06-30 16:15:01 +0200 | [diff] [blame] | 29 | #else |
| 30 | int main(void) { |
| 31 | int ret; |
| 32 | uint8_t buf[64 * 1024]; |
| 33 | |
| 34 | ret = fread(buf, 1, sizeof(buf), stdin); |
| 35 | if (ret < 0) { |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | LLVMFuzzerTestOneInput(buf, ret); |
| 40 | |
| 41 | return 0; |
| 42 | } |
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 43 | #endif /* __AFL_COMPILER */ |