]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1783 in SNORT/snort3 from ~DAVMCPHE/snort3:packet_object_init...
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Wed, 9 Oct 2019 17:04:38 +0000 (13:04 -0400)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Wed, 9 Oct 2019 17:04:38 +0000 (13:04 -0400)
Squashed commit of the following:

commit 74aa43b0bc78b8747eb8a65f8f166390bae6e14a
Author: davis mcpherson <davmcphe@cisco.com>
Date:   Mon Oct 7 10:48:34 2019 -0400

    packet: ensure all member variables of the Packet class are initialized at instantiation and when an instance is reset

src/protocols/packet.cc
src/protocols/packet_manager.cc

index a58bbe9aac0c7481c223d6a37cb633b0cda69c63..904208ab239e0a1244eafa4d6456d19576da344c 100644 (file)
@@ -53,6 +53,7 @@ Packet::Packet(bool packet_data)
     obfuscator = nullptr;
     endianness = nullptr;
     active_inst = new Active;
+    action_inst = nullptr;
     reset();
 }
 
@@ -84,6 +85,12 @@ void Packet::reset()
 
     release_helpers();
     ptrs.reset();
+
+    iplist_id = 0;
+    user_inspection_policy_id = 0;
+    user_ips_policy_id = 0;
+    user_network_policy_id = 0;
+    vlan_idx = 0;
 }
 
 void Packet::release_helpers()
index ac763fefa686dc6b5bd84a230506f0be633a6815..f182abb35b572e8aa49b782b6f5934ff7248a26c 100644 (file)
@@ -613,11 +613,9 @@ const uint8_t* PacketManager::encode_reject(UnreachResponse type,
     }
 }
 
-static void set_hdr(
+static void init_daq_pkthdr(
     const Packet* p, Packet* c, const DAQ_PktHdr_t* phdr, uint32_t opaque)
 {
-    c->reset();
-
     if ( !phdr )
         phdr = p->pkth;
 
@@ -646,7 +644,7 @@ int PacketManager::format_tcp(
     const DAQ_PktHdr_t* phdr, uint32_t opaque)
 {
     c->reset();
-    set_hdr(p, c, phdr, opaque);
+    init_daq_pkthdr(p, c, phdr, opaque);
 
     c->packet_flags |= PKT_PSEUDO;
     c->pseudo_type = type;
@@ -679,7 +677,7 @@ int PacketManager::encode_format(
         return -1;
 
     c->reset();
-    set_hdr(p, c, phdr, opaque);
+    init_daq_pkthdr(p, c, phdr, opaque);
 
     if ( f & ENC_FLAG_NET )
     {