1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include <stdio.h>
- #include <stdint.h>
- #include <stdlib.h>
- #include <pjlib.h>
- #include <pjlib-util.h>
- #include "../../pjlib-util/src/pjlib-util/http_client.c"
- #define kMinInputLength 10
- #define kMaxInputLength 1024
- pj_pool_factory *mem;
- int http_parse(uint8_t *data, size_t Size) {
- int ret;
- pj_pool_t *pool;
- pj_size_t rem;
- pj_http_resp response;
- pool = pj_pool_create(mem, "http", 1000, 1000, NULL);
- ret = http_response_parse(pool, &response, data, Size, &rem);
- pj_pool_release(pool);
- return ret;
- }
- extern int
- LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
- {
- if (Size < kMinInputLength || Size > kMaxInputLength) {
- return 1;
- }
- int ret = 0;
- uint8_t *data;
- pj_caching_pool caching_pool;
-
- data = (uint8_t *)calloc((Size+1), sizeof(uint8_t));
- memcpy((void *)data, (void *)Data, Size);
-
- pj_init();
- pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0);
- pj_log_set_level(0);
- mem = &caching_pool.factory;
-
- ret = http_parse(data, Size);
- free(data);
- pj_caching_pool_destroy(&caching_pool);
- return ret;
- }
|