| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include <stdio.h> |
| 19 |
#include <stdint.h> |
| 20 |
#include <stdlib.h> |
| 21 |
|
| 22 |
#include <pjlib.h> |
| 23 |
#include <pjlib-util.h> |
| 24 |
|
| 25 |
#define kMinInputLength 10 |
| 26 |
#define kMaxInputLength 1024 |
| 27 |
|
| 28 |
pj_pool_factory *mem; |
| 29 |
|
| 30 |
int url_parse(uint8_t *data, size_t Size) { |
| 31 |
|
| 32 |
pj_str_t surl; |
| 33 |
pj_http_url hurl; |
| 34 |
|
| 35 |
surl.ptr = (char *)data; |
| 36 |
surl.slen = Size; |
| 37 |
|
| 38 |
return pj_http_req_parse_url(&surl, &hurl); |
| 39 |
} |
| 40 |
|
| 41 |
extern int |
| 42 |
LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) |
| 43 |
{ |
| 44 |
|
| 45 |
if (Size < kMinInputLength || Size > kMaxInputLength) { |
| 46 |
return 1; |
| 47 |
} |
| 48 |
|
| 49 |
int ret = 0; |
| 50 |
uint8_t *data; |
| 51 |
pj_caching_pool caching_pool; |
| 52 |
|
| 53 |
|
| 54 |
data = (uint8_t *)calloc((Size+1), sizeof(uint8_t)); |
| 55 |
memcpy((void *)data, (void *)Data, Size); |
| 56 |
|
| 57 |
|
| 58 |
pj_init(); |
| 59 |
pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0); |
| 60 |
pj_log_set_level(0); |
| 61 |
|
| 62 |
mem = &caching_pool.factory; |
| 63 |
|
| 64 |
|
| 65 |
ret = url_parse(data, Size); |
| 66 |
|
| 67 |
free(data); |
| 68 |
pj_caching_pool_destroy(&caching_pool); |
| 69 |
|
| 70 |
return ret; |
| 71 |
} |