Coverage Report

Created: 2025-10-12 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/tests/fuzzing/gtp-message-fuzz.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
3
 *
4
 * This file is part of Open5GS.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
#include <stdio.h>
21
#include <stdint.h>
22
23
#include "fuzzing.h"
24
#include "ogs-gtp.h"
25
26
7.66k
#define kMinInputLength 5
27
3.82k
#define kMaxInputLength 1024
28
29
extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) 
30
3.83k
{ /* open5gs/tests/non3gpp/gtp-path.c */
31
32
3.83k
    if (Size < kMinInputLength || Size > kMaxInputLength) {
33
51
        return 1;
34
51
    }
35
36
3.78k
    if (!initialized) {
37
2
        initialize();
38
2
        ogs_log_install_domain(&__ogs_gtp_domain, "gtp", OGS_LOG_NONE);
39
2
        ogs_log_install_domain(&__ogs_tlv_domain, "tlv", OGS_LOG_NONE);
40
2
    }
41
42
3.78k
    ogs_pkbuf_t *pkbuf;
43
3.78k
    pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
44
45
3.78k
    if (pkbuf == NULL) {
46
0
        return 1;
47
0
    }
48
3.78k
    ogs_pkbuf_put_data(pkbuf, Data, Size);
49
50
3.78k
    ogs_gtp2_message_t gtp_message;
51
3.78k
    ogs_gtp2_parse_msg(&gtp_message, pkbuf);
52
53
3.78k
    ogs_pkbuf_free(pkbuf);
54
55
3.78k
    return 0;
56
3.78k
}