]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode/vxlan: Delay var init until needed
authorJeff Lucovsky <jeff@lucovsky.org>
Mon, 24 May 2021 12:03:02 +0000 (08:03 -0400)
committerVictor Julien <victor@inliniac.net>
Fri, 4 Jun 2021 10:02:58 +0000 (12:02 +0200)
This commit modifies the var initialization slightly until after
integrity checks have been performed.

src/decode-vxlan.c

index e08a4873c0a23de4fbf126cb4c6f5191616c96ce..6a7322993ee6390116b3e11785fcc4f438ca7997 100644 (file)
@@ -126,10 +126,7 @@ void DecodeVXLANConfig(void)
 int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         const uint8_t *pkt, uint32_t len)
 {
-    EthernetHdr *ethh = (EthernetHdr *)(pkt + VXLAN_HEADER_LEN);
-
-    uint16_t eth_type;
-    int decode_tunnel_proto = DECODE_TUNNEL_UNSET;
+    DEBUG_VALIDATE_BUG_ON(pkt == NULL);
 
     /* Initial packet validation */
     if (unlikely(!g_vxlan_enabled))
@@ -153,8 +150,11 @@ int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
     /* Increment stats counter for VXLAN packets */
     StatsIncr(tv, dtv->counter_vxlan);
 
+    EthernetHdr *ethh = (EthernetHdr *)(pkt + VXLAN_HEADER_LEN);
+    int decode_tunnel_proto = DECODE_TUNNEL_UNSET;
+
     /* Look at encapsulated Ethernet frame to get next protocol  */
-    eth_type = SCNtohs(ethh->eth_type);
+    uint16_t eth_type = SCNtohs(ethh->eth_type);
     SCLogDebug("VXLAN ethertype 0x%04x", eth_type);
 
     switch (eth_type) {