git/oss-fuzz/fuzz-parse-attr-line.c
Junio C Hamano 7b39a128c8 Merge branch 'ps/the-repository'
More code paths have a repository passed through the callchain,
instead of assuming the primary the_repository object.

* ps/the-repository:
  match-trees: stop using `the_repository`
  graph: stop using `the_repository`
  add-interactive: stop using `the_repository`
  tmp-objdir: stop using `the_repository`
  resolve-undo: stop using `the_repository`
  credential: stop using `the_repository`
  mailinfo: stop using `the_repository`
  diagnose: stop using `the_repository`
  server-info: stop using `the_repository`
  send-pack: stop using `the_repository`
  serve: stop using `the_repository`
  trace: stop using `the_repository`
  pager: stop using `the_repository`
  progress: stop using `the_repository`
2025-01-21 08:44:54 -08:00

42 lines
732 B
C

#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "attr.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
struct match_attr *res;
char *buf;
buf = malloc(size + 1);
if (!buf)
return 0;
memcpy(buf, data, size);
buf[size] = 0;
res = parse_attr_line(buf, "dummy", 0, 0);
if (res) {
size_t j;
for (j = 0; j < res->num_attr; j++) {
const char *setto = res->state[j].setto;
if (ATTR_TRUE(setto) || ATTR_FALSE(setto) ||
ATTR_UNSET(setto))
;
else
free((char *)setto);
}
free(res);
}
free(buf);
return 0;
}