/src/git/oss-fuzz/fuzz-credential-from-url-gently.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 | | #include <stddef.h> |
13 | | #include <stdlib.h> |
14 | | #include <stdint.h> |
15 | | #include <string.h> |
16 | | #include <stdio.h> |
17 | | #include "git-compat-util.h" |
18 | | #include "credential.h" |
19 | | |
20 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
21 | 1.02k | { |
22 | 1.02k | char *buf; |
23 | | |
24 | 1.02k | buf = malloc(size + 1); |
25 | 1.02k | if (!buf) |
26 | 0 | return 0; |
27 | | |
28 | 1.02k | memcpy(buf, data, size); |
29 | 1.02k | buf[size] = 0; |
30 | | |
31 | | // start fuzzing |
32 | 1.02k | struct credential c; |
33 | 1.02k | credential_init(&c); |
34 | 1.02k | credential_from_url_gently(&c, buf, 1); |
35 | | |
36 | | // cleanup |
37 | 1.02k | credential_clear(&c); |
38 | 1.02k | free(buf); |
39 | | |
40 | 1.02k | return 0; |
41 | 1.02k | } |