Raw
1 #define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "git-compat-util.h"
4 #include <stddef.h>
5 #include <stdlib.h>
6 #include <stdint.h>
7 #include <string.h>
8 #include "attr.h"
9
10 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
11
12 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
13 {
14 struct match_attr *res;
15 char *buf;
16
17 buf = malloc(size + 1);
18 if (!buf)
19 return 0;
20
21 memcpy(buf, data, size);
22 buf[size] = 0;
23
24 res = parse_attr_line(buf, "dummy", 0, 0);
25
26 if (res) {
27 size_t j;
28 for (j = 0; j < res->num_attr; j++) {
29 const char *setto = res->state[j].setto;
30 if (ATTR_TRUE(setto) || ATTR_FALSE(setto) ||
31 ATTR_UNSET(setto))
32 ;
33 else
34 free((char *)setto);
35 }
36 free(res);
37 }
38 free(buf);
39
40 return 0;
41 }