forked from mayhemheroes/mayhem-cmake-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuzzme.c
49 lines (38 loc) · 836 Bytes
/
fuzzme.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int fuzzme(char *buf)
{
if(strlen(buf) >= 3)
if(buf[0] == 'b')
if(buf[1] == 'u')
if(buf[2] == 'g') {
printf("You've got it!");
abort();
}
return 0;
}
#define BUFSZ 256
int LLVMFuzzerTestOneInput(char *data, size_t size) {
fuzzme(data);
return 0;
}
// int main(int argc, char** argv)
// {
// char buf[BUFSZ] = { 0 };
// FILE* f = NULL;
// size_t nr = 0;
// if (2 > argc) {
// fprintf(stderr, "usage: %s PAYLOAD\n", argv[0]);
// return 1;
// }
// f = fopen(argv[1], "rb");
// assert(f);
// nr = fread(buf, sizeof(buf[0]), BUFSZ, f);
// assert(nr > 0);
// buf[BUFSZ-1] = '\0';
// fuzzme(buf);
// fclose(f);
// return 0;
// }