]> git.proxmox.com Git - libgit2.git/blame - fuzzers/patch_parse_fuzzer.c
Update d/ch for 1.1.0+dfsg.1-3 release
[libgit2.git] / fuzzers / patch_parse_fuzzer.c
CommitLineData
0c9c969a
UG
1/*
2 * libgit2 patch parser 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 "git2.h"
11#include "patch.h"
12#include "patch_parse.h"
13
14#define UNUSED(x) (void)(x)
15
16int LLVMFuzzerInitialize(int *argc, char ***argv)
17{
18 UNUSED(argc);
19 UNUSED(argv);
20
21 if (git_libgit2_init() < 0)
22 abort();
23
24 return 0;
25}
26
27int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
28{
29 if (size) {
30 git_patch *patch = NULL;
31 git_patch_options opts = GIT_PATCH_OPTIONS_INIT;
32 opts.prefix_len = (uint32_t)data[0];
33 git_patch_from_buffer(&patch, (const char *)data + 1, size - 1,
34 &opts);
35 git_patch_free(patch);
36 }
37 return 0;
38}