/src/git/oss-fuzz/fuzz-cmd-bundle-verify.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /* Copyright 2024 Google LLC  | 
2  |  | Licensed under the Apache License, Version 2.0 (the "License");  | 
3  |  | you may not use this file except in compliance with the License.  | 
4  |  | You may obtain a copy of the License at  | 
5  |  |     http://www.apache.org/licenses/LICENSE-2.0  | 
6  |  | Unless required by applicable law or agreed to in writing, software  | 
7  |  | distributed under the License is distributed on an "AS IS" BASIS,  | 
8  |  | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
9  |  | See the License for the specific language governing permissions and  | 
10  |  | limitations under the License.  | 
11  |  | */  | 
12  |  | #define USE_THE_REPOSITORY_VARIABLE  | 
13  |  |  | 
14  |  | #include <stddef.h>  | 
15  |  | #include <stdint.h>  | 
16  |  | #include "fuzz-cmd-base.h"  | 
17  |  | #include "git-compat-util.h"  | 
18  |  | #include "repository.h"  | 
19  |  | #include "builtin.h"  | 
20  |  |  | 
21  |  | int cmd_init_db(int argc, const char **argv, const char *prefix);  | 
22  |  | int cmd_bundle_verify(int argc, const char **argv, const char *prefix);  | 
23  |  |  | 
24  |  | static int initialized = 0;  | 
25  |  |  | 
26  |  | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)  | 
27  | 188  | { | 
28  | 188  |   char *argv[4];  | 
29  |  |  | 
30  | 188  |   if (!initialized)  | 
31  | 1  |   { | 
32  | 1  |     put_envs();  | 
33  | 1  |     create_templ_dir();  | 
34  | 1  |     initialized = 1;  | 
35  | 1  |   }  | 
36  |  |  | 
37  | 188  |   initialize_repository(the_repository);  | 
38  |  |  | 
39  | 188  |   argv[0] = "init";  | 
40  | 188  |   argv[1] = "--quiet";  | 
41  | 188  |   argv[2] = NULL;  | 
42  | 188  |   if (cmd_init_db(2, (const char **)argv, (const char *)""))  | 
43  | 0  |     exit(1);  | 
44  |  |  | 
45  | 188  |   if (randomize_git_file("/tmp", "fuzz.bundle", data, size)) | 
46  | 0  |     goto cleanup;  | 
47  |  |  | 
48  | 188  |   argv[0] = "bundle";  | 
49  | 188  |   argv[1] = "--quiet";  | 
50  | 188  |   argv[2] = "/tmp/fuzz.bundle";  | 
51  | 188  |   argv[3] = NULL;  | 
52  | 188  |   cmd_bundle_verify(3, (const char **)argv, (const char *)"");  | 
53  |  |  | 
54  | 188  | cleanup:  | 
55  | 188  |   repo_clear(the_repository);  | 
56  | 188  |   return 0;  | 
57  | 188  | }  |