Hopefully the final batch before 2.48-rc1
[git/gitster.git] / oss-fuzz / fuzz-url-decode-mem.c
blob2342aa993b8aef2e757d260977b6a84835e1847a
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"
9 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
11 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
13 char *buf;
14 char *r;
15 const char *pbuf;
17 buf = malloc(size + 1);
18 if (!buf)
19 return 0;
21 memcpy(buf, data, size);
22 buf[size] = 0;
24 // start fuzzing
25 r = url_decode(buf);
26 free(r);
28 r = url_percent_decode(buf);
29 free(r);
31 pbuf = (const char*) buf;
32 r = url_decode_parameter_name(&pbuf);
33 free(r);
35 pbuf = (const char*) buf;
36 r = url_decode_parameter_value(&pbuf);
37 free(r);
39 // cleanup
40 free(buf);
42 return 0;