blob: a4b64b5006633dc039e81256dacb3fa6a8f28650 [file] [log] [blame]
Juraj Vijtiuk260407e2020-03-18 10:32:13 +01001#include <stdio.h>
2#include <stdint.h>
3#include <stdlib.h>
4
Juraj Vijtiukdba28812020-09-24 13:56:18 +02005int LLVMFuzzerTestOneInput(uint8_t const *buf, size_t len);
6
Juraj Vijtiuk260407e2020-03-18 10:32:13 +01007#ifdef __AFL_COMPILER
8
9int main(void) {
Michal Vaskob9878502022-11-11 10:00:05 +010010 int ret;
11 uint8_t buf[64 * 1024];
Juraj Vijtiuk260407e2020-03-18 10:32:13 +010012
13#ifdef __AFL_LOOP
Michal Vaskob9878502022-11-11 10:00:05 +010014 while (__AFL_LOOP(10000))
Juraj Vijtiuk260407e2020-03-18 10:32:13 +010015#endif
Michal Vaskob9878502022-11-11 10:00:05 +010016 {
17 ret = fread(buf, 1, sizeof(buf), stdin);
18 if (ret < 0) {
19 return 0;
20 }
Juraj Vijtiuk260407e2020-03-18 10:32:13 +010021
Michal Vaskob9878502022-11-11 10:00:05 +010022 LLVMFuzzerTestOneInput(buf, ret);
Juraj Vijtiuk260407e2020-03-18 10:32:13 +010023
Michal Vaskob9878502022-11-11 10:00:05 +010024 }
Juraj Vijtiuk260407e2020-03-18 10:32:13 +010025
Michal Vaskob9878502022-11-11 10:00:05 +010026 return 0;
Juraj Vijtiuk260407e2020-03-18 10:32:13 +010027}
28
Juraj Vijtiukc496e6f2020-06-30 16:15:01 +020029#else
Juraj Vijtiukc496e6f2020-06-30 16:15:01 +020030
Michal Vaskob9878502022-11-11 10:00:05 +010031int
32main(void)
33{
34 int ret;
35 uint8_t buf[64 * 1024];
Juraj Vijtiukc496e6f2020-06-30 16:15:01 +020036
Michal Vaskob9878502022-11-11 10:00:05 +010037 ret = fread(buf, 1, sizeof(buf), stdin);
38 if (ret < 0) {
39 return 0;
40 }
Juraj Vijtiukc496e6f2020-06-30 16:15:01 +020041
Michal Vaskob9878502022-11-11 10:00:05 +010042 LLVMFuzzerTestOneInput(buf, ret);
43
44 return 0;
Juraj Vijtiukc496e6f2020-06-30 16:15:01 +020045}
Michal Vaskob9878502022-11-11 10:00:05 +010046
Juraj Vijtiuk260407e2020-03-18 10:32:13 +010047#endif /* __AFL_COMPILER */