Coverage Report

Created: 2025-11-11 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libgit2/fuzzers/revparse_fuzzer.c
Line
Count
Source
1
/*
2
 * libgit2 revparse fuzzer target.
3
 *
4
 * Copyright (C) the libgit2 contributors. All rights reserved.
5
 *
6
 * This file is part of libgit2, distributed under the GNU GPL v2 with
7
 * a Linking Exception. For full terms see the included COPYING file.
8
 */
9
10
#include <stdio.h>
11
#include <string.h>
12
13
#include "git2.h"
14
15
#include "standalone_driver.h"
16
#include "fuzzer_utils.h"
17
18
8
#define UNUSED(x) (void)(x)
19
20
static git_repository *repo;
21
22
int LLVMFuzzerInitialize(int *argc, char ***argv)
23
4
{
24
4
  UNUSED(argc);
25
4
  UNUSED(argv);
26
27
4
  if (git_libgit2_init() < 0)
28
0
    abort();
29
30
4
  if (git_libgit2_opts(GIT_OPT_SET_PACK_MAX_OBJECTS, 10000000) < 0)
31
0
    abort();
32
33
4
  repo = fuzzer_repo_init();
34
4
  return 0;
35
4
}
36
37
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
38
14.3k
{
39
14.3k
  git_object *obj = NULL;
40
14.3k
  char *c;
41
42
14.3k
  if ((c = calloc(1, size + 1)) == NULL)
43
0
    abort();
44
45
14.3k
  memcpy(c, data, size);
46
47
14.3k
  git_revparse_single(&obj, repo, c);
48
14.3k
  git_object_free(obj);
49
14.3k
  free(c);
50
51
14.3k
  return 0;
52
14.3k
}