| 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 | { |
| 13 | char *buf; |
| 14 | char *r; |
| 15 | const char *pbuf; |
| 16 | |
| 17 | buf = malloc(size + 1); |
| 18 | if (!buf) |
| 19 | return 0; |
| 20 | |
| 21 | memcpy(buf, data, size); |
| 22 | buf[size] = 0; |
| 23 | |
| 24 | // start fuzzing |
| 25 | r = url_decode(buf); |
| 26 | free(r); |
| 27 | |
| 28 | r = url_percent_decode(buf); |
| 29 | free(r); |
| 30 | |
| 31 | pbuf = (const char*) buf; |
| 32 | r = url_decode_parameter_name(&pbuf); |
| 33 | free(r); |
| 34 | |
| 35 | pbuf = (const char*) buf; |
| 36 | r = url_decode_parameter_value(&pbuf); |
| 37 | free(r); |
| 38 | |
| 39 | // cleanup |
| 40 | free(buf); |
| 41 | |
| 42 | return 0; |
| 43 | } |