Coverage Report

Created: 2026-10-16 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/tests/fuzzing/ngap-message-fuzz.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2019-2026 by Arthur SC Chan <arthur.chan@adalogics.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-ngap.h"
25
26
18.3k
#define kMinInputLength 5
27
9.18k
#define kMaxInputLength 2048
28
29
extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
30
9.19k
{
31
32
9.19k
    if (Size < kMinInputLength || Size > kMaxInputLength) {
33
51
        return 1;
34
51
    }
35
36
9.14k
    if (!initialized) {
37
2
        initialize();
38
2
        ogs_log_install_domain(&__ogs_ngap_domain, "ngap", OGS_LOG_NONE);
39
2
    }
40
41
9.14k
    int result;
42
9.14k
    ogs_pkbuf_t *pkbuf;
43
9.14k
    ogs_ngap_message_t message;
44
45
9.14k
    pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
46
9.14k
    if (pkbuf == NULL) {
47
0
        return 1;
48
0
    }
49
50
9.14k
    ogs_pkbuf_put_data(pkbuf, Data, Size);
51
52
9.14k
    result = ogs_ngap_decode(&message, pkbuf);
53
9.14k
    if (result == OGS_OK) {
54
137
        ogs_ngap_free(&message);
55
137
    }
56
57
9.14k
    ogs_pkbuf_free(pkbuf);
58
59
9.14k
    return 0;
60
9.14k
}