• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 23352517976

20 Mar 2026 04:32PM UTC coverage: 65.866% (-13.4%) from 79.315%
23352517976

Pull #15072

github

web-flow
Merge abcd1935f into 6587e363a
Pull Request #15072: Stack 8001 v16.3

41 of 70 new or added lines in 10 files covered. (58.57%)

18894 existing lines in 577 files now uncovered.

143735 of 218225 relevant lines covered (65.87%)

4342818.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.58
/src/decode-null.c
1
/* Copyright (C) 2015-2021 Open Information Security Foundation
2
 *
3
 * You can copy, redistribute or modify this Program under the terms of
4
 * the GNU General Public License version 2 as published by the Free
5
 * Software Foundation.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * version 2 along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
 * 02110-1301, USA.
16
 */
17

18
/**
19
 * \ingroup decode
20
 *
21
 * @{
22
 */
23

24
/**
25
 * \file
26
 *
27
 * \author Victor Julien <victor@inliniac.net>
28
 *
29
 * Decode linktype null:
30
 * http://www.tcpdump.org/linktypes.html
31
 */
32

33
#include "suricata-common.h"
34
#include "decode.h"
35
#include "decode-raw.h"
36
#include "decode-events.h"
37

38
#include "util-validate.h"
39
#include "util-unittest.h"
40
#include "util-debug.h"
41

42
#define HDR_SIZE 4
21,255✔
43

UNCOV
44
#define AF_INET6_BSD     24
×
UNCOV
45
#define AF_INET6_FREEBSD 28
×
46
#define AF_INET6_DARWIN  30
118✔
47
#define AF_INET6_LINUX   10
118✔
48
#define AF_INET6_SOLARIS 26
118✔
49
#define AF_INET6_WINSOCK 23
118✔
50

51
int DecodeNull(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
52
        const uint8_t *pkt, uint32_t len)
53
{
7,085✔
54
    DEBUG_VALIDATE_BUG_ON(pkt == NULL);
7,085✔
55

56
    StatsCounterIncr(&tv->stats, dtv->counter_null);
7,085✔
57

58
    if (unlikely(len < HDR_SIZE)) {
7,085✔
UNCOV
59
        ENGINE_SET_INVALID_EVENT(p, LTNULL_PKT_TOO_SMALL);
×
UNCOV
60
        return TM_ECODE_FAILED;
×
UNCOV
61
    }
×
62

63
    if (unlikely(GET_PKT_LEN(p) > HDR_SIZE + USHRT_MAX)) {
7,085✔
UNCOV
64
        return TM_ECODE_FAILED;
×
UNCOV
65
    }
×
66
#if __BYTE_ORDER__ == __BIG_ENDIAN
67
    uint32_t type = pkt[0] | pkt[1] << 8 | pkt[2] << 16 | pkt[3] << 24;
68
#else
69
    uint32_t type = *((uint32_t *)pkt);
7,085✔
70
#endif
7,085✔
71
    switch(type) {
7,085✔
72
        case AF_INET:
6,967✔
73
            SCLogDebug("IPV4 Packet");
6,967✔
74
            if (GET_PKT_LEN(p) - HDR_SIZE > USHRT_MAX) {
6,967✔
75
                return TM_ECODE_FAILED;
×
76
            }
×
77
            DecodeIPV4(
6,967✔
78
                    tv, dtv, p, GET_PKT_DATA(p) + HDR_SIZE, (uint16_t)(GET_PKT_LEN(p) - HDR_SIZE));
6,967✔
79
            break;
6,967✔
UNCOV
80
        case AF_INET6_BSD:
×
UNCOV
81
        case AF_INET6_FREEBSD:
×
82
        case AF_INET6_DARWIN:
118✔
83
        case AF_INET6_LINUX:
118✔
84
        case AF_INET6_SOLARIS:
118✔
85
        case AF_INET6_WINSOCK:
118✔
86
            SCLogDebug("IPV6 Packet");
118✔
87
            if (GET_PKT_LEN(p) - HDR_SIZE > USHRT_MAX) {
118✔
88
                return TM_ECODE_FAILED;
×
89
            }
×
90
            DecodeIPV6(
118✔
91
                    tv, dtv, p, GET_PKT_DATA(p) + HDR_SIZE, (uint16_t)(GET_PKT_LEN(p) - HDR_SIZE));
118✔
92
            break;
118✔
UNCOV
93
        default:
×
UNCOV
94
            SCLogDebug("Unknown Null packet type version %" PRIu32 "", type);
×
UNCOV
95
            ENGINE_SET_EVENT(p, LTNULL_UNSUPPORTED_TYPE);
×
UNCOV
96
            break;
×
97
    }
7,085✔
98
    return TM_ECODE_OK;
7,085✔
99
}
7,085✔
100

101
/**
102
 * @}
103
 */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc