]> git.proxmox.com Git - libgit2.git/blame - fuzzers/patch_parse_fuzzer.c
New upstream version 1.5.0+ds
[libgit2.git] / fuzzers / patch_parse_fuzzer.c
CommitLineData
22a2d3d5
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
e579e0f7
MB
14#include "standalone_driver.h"
15
22a2d3d5
UG
16#define UNUSED(x) (void)(x)
17
18int LLVMFuzzerInitialize(int *argc, char ***argv)
19{
20 UNUSED(argc);
21 UNUSED(argv);
22
23 if (git_libgit2_init() < 0)
24 abort();
25
26 return 0;
27}
28
29int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
30{
31 if (size) {
32 git_patch *patch = NULL;
33 git_patch_options opts = GIT_PATCH_OPTIONS_INIT;
34 opts.prefix_len = (uint32_t)data[0];
35 git_patch_from_buffer(&patch, (const char *)data + 1, size - 1,
36 &opts);
37 git_patch_free(patch);
38 }
39 return 0;
40}