Coverage Report

Created: 2026-02-26 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pjsip/tests/fuzz/fuzz-vpx.c
Line
Count
Source
1
/* 
2
 * Copyright (C) 2023 Teluu Inc. (http://www.teluu.com)
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 2 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
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
124
#define kMinInputLength 10
27
56
#define kMaxInputLength 5120
28
29
pj_pool_factory *mem;
30
31
int vpx_unpacketizer(const uint8_t *data, size_t size)
32
38
{
33
38
    int ret = 0;
34
38
    pj_pool_t *pool;
35
38
    pj_status_t status;
36
38
    pjmedia_vpx_packetizer_cfg cfg;
37
38
    pjmedia_vpx_packetizer *pktz;
38
38
    unsigned desc_len = 0;
39
40
38
    pool = pj_pool_create(mem, "vpx_test", 1000, 1000, NULL);
41
42
38
    pj_bzero(&cfg, sizeof(cfg));
43
44
38
    status = pjmedia_vpx_packetizer_create(pool, &cfg, &pktz);
45
46
38
    if (status == PJ_SUCCESS) {
47
0
        status = pjmedia_vpx_unpacketize(pktz, data, size, &desc_len);
48
0
    }
49
50
38
    pj_pool_release(pool);
51
52
38
    return ret;
53
38
}
54
55
extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
56
62
{
57
62
    int ret = 0;
58
62
    uint8_t *data;
59
62
    pj_caching_pool caching_pool;
60
61
62
    if (Size < kMinInputLength || Size > kMaxInputLength) {
62
24
        return 1;
63
24
    }
64
65
    /* Add null termination for the data */
66
38
    data = (uint8_t *)calloc((Size+1), sizeof(uint8_t));
67
38
    memcpy((void *)data, (void *)Data, Size);
68
69
    /* Init */
70
38
    pj_init();
71
38
    pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
72
38
    pj_log_set_level(0);
73
74
38
    mem = &caching_pool.factory;
75
76
    /* Fuzz */
77
38
    ret = vpx_unpacketizer(data, Size);
78
79
38
    free(data);
80
38
    pj_caching_pool_destroy(&caching_pool);
81
82
38
    return ret;
83
62
}
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