Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright 2021 Google LLC |
2 | | |
3 | | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | you may not use this file except in compliance with the License. |
5 | | You may obtain a copy of the License at |
6 | | |
7 | | http://www.apache.org/licenses/LICENSE-2.0 |
8 | | |
9 | | Unless required by applicable law or agreed to in writing, software |
10 | | distributed under the License is distributed on an "AS IS" BASIS, |
11 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | See the License for the specific language governing permissions and |
13 | | limitations under the License. |
14 | | */ |
15 | | |
16 | | #include <stdio.h> |
17 | | #include <stdlib.h> |
18 | | #include <stdint.h> |
19 | | #include <string.h> |
20 | | |
21 | | #include "burl.h" |
22 | | #include "buffer.h" |
23 | | |
24 | | void run_burl_normalize (buffer *psrc, buffer *ptmp, |
25 | | int flags, int line, const char *in, |
26 | 1.70k | size_t in_len) { |
27 | 1.70k | int qs; |
28 | 1.70k | buffer_copy_string_len(psrc, in, in_len); |
29 | 1.70k | qs = burl_normalize(psrc, ptmp, flags); |
30 | 1.70k | } |
31 | | |
32 | 1.70k | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
33 | 1.70k | if (size <= 4) { |
34 | 4 | return 0; |
35 | 4 | } |
36 | 1.70k | int flags = ((int*)data)[0]; |
37 | 1.70k | data += 4; |
38 | 1.70k | size -= 4; |
39 | 1.70k | char *new_str = (char *)malloc(size+1); |
40 | 1.70k | if (new_str == NULL){ |
41 | 0 | return 0; |
42 | 0 | } |
43 | 1.70k | memcpy(new_str, data, size); |
44 | 1.70k | new_str[size] = '\0'; |
45 | | |
46 | | /* main fuzzer entrypoint for library */ |
47 | 1.70k | buffer *psrc = buffer_init(); |
48 | 1.70k | buffer *ptmp = buffer_init(); |
49 | 1.70k | run_burl_normalize(psrc, ptmp, flags, __LINE__, new_str, size); |
50 | 1.70k | buffer_urldecode_path(psrc); |
51 | | |
52 | 1.70k | buffer_free(psrc); |
53 | 1.70k | buffer_free(ptmp); |
54 | 1.70k | free(new_str); |
55 | 1.70k | return 0; |
56 | 1.70k | } |