/src/opensips/parser/fuzz_uri_parser.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright 2021 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 "../cachedb/test/test_cachedb.h" |
13 | | #include "../lib/test/test_csv.h" |
14 | | #include "../mem/test/test_malloc.h" |
15 | | #include "../str.h" |
16 | | |
17 | | #include "../dprint.h" |
18 | | #include "../globals.h" |
19 | | #include "../lib/list.h" |
20 | | #include "../sr_module.h" |
21 | | #include "../sr_module_deps.h" |
22 | | |
23 | | #include "parse_uri.h" |
24 | | |
25 | | #include "../test/fuzz/fuzz_standalone.h" |
26 | | |
27 | 5.75k | int LLVMFuzzerTestOneInput(const char *data, size_t size) { |
28 | 5.75k | struct sip_uri u; |
29 | | |
30 | 5.75k | char *new_str = (char *)malloc(size + 1); |
31 | 5.75k | if (new_str == NULL) { |
32 | 0 | return 0; |
33 | 0 | } |
34 | 5.75k | memcpy(new_str, data, size); |
35 | 5.75k | new_str[size] = '\0'; |
36 | | |
37 | 5.75k | parse_uri(STR_L(new_str), &u); |
38 | | |
39 | 5.75k | free(new_str); |
40 | 5.75k | return (0); |
41 | 5.75k | } |