/src/git/oss-fuzz/fuzz-url-decode-mem.c
Line | Count | Source |
1 | | #include "git-compat-util.h" |
2 | | #include <stddef.h> |
3 | | #include <stdlib.h> |
4 | | #include <stdint.h> |
5 | | #include <string.h> |
6 | | #include <stdio.h> |
7 | | #include "url.h" |
8 | | |
9 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); |
10 | | |
11 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
12 | 435 | { |
13 | 435 | char *buf; |
14 | 435 | char *r; |
15 | 435 | const char *pbuf; |
16 | | |
17 | 435 | buf = malloc(size + 1); |
18 | 435 | if (!buf) |
19 | 0 | return 0; |
20 | | |
21 | 435 | memcpy(buf, data, size); |
22 | 435 | buf[size] = 0; |
23 | | |
24 | | // start fuzzing |
25 | 435 | r = url_decode(buf); |
26 | 435 | free(r); |
27 | | |
28 | 435 | r = url_percent_decode(buf); |
29 | 435 | free(r); |
30 | | |
31 | 435 | pbuf = (const char*) buf; |
32 | 435 | r = url_decode_parameter_name(&pbuf); |
33 | 435 | free(r); |
34 | | |
35 | 435 | pbuf = (const char*) buf; |
36 | 435 | r = url_decode_parameter_value(&pbuf); |
37 | 435 | free(r); |
38 | | |
39 | | // cleanup |
40 | 435 | free(buf); |
41 | | |
42 | 435 | return 0; |
43 | 435 | } |