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) { | ||||
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 10 | int ret; |
11 | uint8_t buf[64 * 1024]; | ||||
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 12 | |
13 | #ifdef __AFL_LOOP | ||||
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 14 | while (__AFL_LOOP(10000)) |
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 15 | #endif |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 16 | { |
17 | ret = fread(buf, 1, sizeof(buf), stdin); | ||||
18 | if (ret < 0) { | ||||
19 | return 0; | ||||
20 | } | ||||
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 21 | |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 22 | LLVMFuzzerTestOneInput(buf, ret); |
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 23 | |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 24 | } |
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 25 | |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 26 | return 0; |
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 27 | } |
28 | |||||
Juraj Vijtiuk | c496e6f | 2020-06-30 16:15:01 +0200 | [diff] [blame] | 29 | #else |
Juraj Vijtiuk | c496e6f | 2020-06-30 16:15:01 +0200 | [diff] [blame] | 30 | |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 31 | int |
32 | main(void) | ||||
33 | { | ||||
34 | int ret; | ||||
35 | uint8_t buf[64 * 1024]; | ||||
Juraj Vijtiuk | c496e6f | 2020-06-30 16:15:01 +0200 | [diff] [blame] | 36 | |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 37 | ret = fread(buf, 1, sizeof(buf), stdin); |
38 | if (ret < 0) { | ||||
39 | return 0; | ||||
40 | } | ||||
Juraj Vijtiuk | c496e6f | 2020-06-30 16:15:01 +0200 | [diff] [blame] | 41 | |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 42 | LLVMFuzzerTestOneInput(buf, ret); |
43 | |||||
44 | return 0; | ||||
Juraj Vijtiuk | c496e6f | 2020-06-30 16:15:01 +0200 | [diff] [blame] | 45 | } |
Michal Vasko | b987850 | 2022-11-11 10:00:05 +0100 | [diff] [blame^] | 46 | |
Juraj Vijtiuk | 260407e | 2020-03-18 10:32:13 +0100 | [diff] [blame] | 47 | #endif /* __AFL_COMPILER */ |