]>
git.proxmox.com Git - libgit2.git/blob - fuzzers/config_file_fuzzer.c
2 * libgit2 config file parser fuzz target.
4 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
11 #include "config_backend.h"
13 #define UNUSED(x) (void)(x)
15 int foreach_cb(const git_config_entry
*entry
, void *payload
)
23 int LLVMFuzzerInitialize(int *argc
, char ***argv
)
28 if (git_libgit2_init() < 0)
34 int LLVMFuzzerTestOneInput(const uint8_t *data
, size_t size
)
36 git_config
*cfg
= NULL
;
37 git_config_backend
*backend
= NULL
;
40 if ((err
= git_config_new(&cfg
)) != 0) {
44 if ((err
= git_config_backend_from_string(&backend
, (const char*)data
, size
)) != 0) {
47 if ((err
= git_config_add_backend(cfg
, backend
, 0, NULL
, 0)) != 0) {
50 /* Now owned by the config */
53 git_config_foreach(cfg
, foreach_cb
, NULL
);
55 git_config_backend_free(backend
);