interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / oss-fuzz / fuzz-parse-attr-line.c

41 lines · 732 bytes Raw Blame History
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
10int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
11
12int 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}