| 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 <pjmedia-codec/vpx_packetizer.h> |
| 24 |
|
| 25 |
#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0) |
| 26 |
#define kMinInputLength 10 |
| 27 |
#define kMaxInputLength 5120 |
| 28 |
|
| 29 |
pj_pool_factory *mem; |
| 30 |
|
| 31 |
int vpx_unpacketizer(const uint8_t *data, size_t size) |
| 32 |
{ |
| 33 |
int ret = 0; |
| 34 |
pj_pool_t *pool; |
| 35 |
pj_status_t status; |
| 36 |
pjmedia_vpx_packetizer_cfg cfg; |
| 37 |
pjmedia_vpx_packetizer *pktz; |
| 38 |
unsigned desc_len = 0; |
| 39 |
|
| 40 |
pool = pj_pool_create(mem, "vpx_test", 1000, 1000, NULL); |
| 41 |
|
| 42 |
pj_bzero(&cfg, sizeof(cfg)); |
| 43 |
|
| 44 |
status = pjmedia_vpx_packetizer_create(pool, &cfg, &pktz); |
| 45 |
|
| 46 |
if (status == PJ_SUCCESS) { |
| 47 |
status = pjmedia_vpx_unpacketize(pktz, data, size, &desc_len); |
| 48 |
} |
| 49 |
|
| 50 |
pj_pool_release(pool); |
| 51 |
|
| 52 |
return ret; |
| 53 |
} |
| 54 |
|
| 55 |
extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) |
| 56 |
{ |
| 57 |
int ret = 0; |
| 58 |
uint8_t *data; |
| 59 |
pj_caching_pool caching_pool; |
| 60 |
|
| 61 |
if (Size < kMinInputLength || Size > kMaxInputLength) { |
| 62 |
return 1; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
data = (uint8_t *)calloc((Size+1), sizeof(uint8_t)); |
| 67 |
memcpy((void *)data, (void *)Data, Size); |
| 68 |
|
| 69 |
|
| 70 |
pj_init(); |
| 71 |
pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0); |
| 72 |
pj_log_set_level(0); |
| 73 |
|
| 74 |
mem = &caching_pool.factory; |
| 75 |
|
| 76 |
|
| 77 |
ret = vpx_unpacketizer(data, Size); |
| 78 |
|
| 79 |
free(data); |
| 80 |
pj_caching_pool_destroy(&caching_pool); |
| 81 |
|
| 82 |
return ret; |
| 83 |
} |
| 84 |
#else |
| 85 |
extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) |
| 86 |
{ |
| 87 |
PJ_UNUSED_ARG(Data); |
| 88 |
PJ_UNUSED_ARG(Size); |
| 89 |
return 0; |
| 90 |
} |
| 91 |
#endif |