/src/git/oss-fuzz/fuzz-parse-attr-line.c
Line | Count | Source |
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 | 907 | { |
14 | 907 | struct match_attr *res; |
15 | 907 | char *buf; |
16 | | |
17 | 907 | buf = malloc(size + 1); |
18 | 907 | if (!buf) |
19 | 0 | return 0; |
20 | | |
21 | 907 | memcpy(buf, data, size); |
22 | 907 | buf[size] = 0; |
23 | | |
24 | 907 | res = parse_attr_line(buf, "dummy", 0, 0); |
25 | | |
26 | 907 | if (res) { |
27 | 696 | size_t j; |
28 | 10.6k | for (j = 0; j < res->num_attr; j++) { |
29 | 9.95k | const char *setto = res->state[j].setto; |
30 | 9.95k | if (ATTR_TRUE(setto) || ATTR_FALSE(setto) || |
31 | 607 | ATTR_UNSET(setto)) |
32 | 9.57k | ; |
33 | 378 | else |
34 | 378 | free((char *)setto); |
35 | 9.95k | } |
36 | 696 | free(res); |
37 | 696 | } |
38 | 907 | free(buf); |
39 | | |
40 | 907 | return 0; |
41 | 907 | } |