]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1004 in SNORT/snort3 from xcode to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 1 Sep 2017 17:25:44 +0000 (13:25 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Fri, 1 Sep 2017 17:25:44 +0000 (13:25 -0400)
Squashed commit of the following:

commit 657e650852af9bc8a0c39dc986aa94edc1364f21
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Sep 1 09:02:29 2017 -0400

    analyzer: fix possible leak upon appid info table entry dup

commit ade6ed67f5602ffca18447d0b0ac1ad67da4fcd9
Author: Russ Combs <rucombs@cisco.com>
Date:   Fri Sep 1 08:50:07 2017 -0400

    analyzer: fix possible memory leak in side channel

commit 27a9d0a40ec991b938d1f801b32e7fb9fb507ea8
Author: Russ Combs <rucombs@cisco.com>
Date:   Thu Aug 31 19:46:22 2017 -0400

    analyzer: fix missing braces around subobj initialization in flow key

src/flow/flow_key.cc
src/network_inspectors/appid/app_info_table.cc
src/side_channel/side_channel.cc

index 1a1de52adb8e1ddaf92ddd852581fc84b19dcda0..718e1870993c59df6d259555510378873590e247 100644 (file)
@@ -33,7 +33,9 @@
 //-------------------------------------------------------------------------
 // icmp foo
 //-------------------------------------------------------------------------
-static const ip::snort_in6_addr fixed_addr = {0xFF,0,0,0};
+
+static const ip::snort_in6_addr fixed_addr = { { { 0xFF, 0, 0, 0 } } };
+
 inline void FlowKey::update_icmp4(const SfIp*& srcIP, uint16_t& srcPort,
     const SfIp*& dstIP, uint16_t& dstPort)
 {
index a4ea381572ce5c206830150f3ff7a0241810c43e..24ee85a2985f394d20afeab798cda9bfd4fdbbee 100644 (file)
@@ -177,7 +177,12 @@ AppInfoTableEntry* AppInfoManager::add_dynamic_app_entry(const char* app_name)
     {
         entry = new AppInfoTableEntry(next_custom_appid++, snort_strdup(app_name));
         custom_app_info_table[entry->appId] = entry;
-        add_entry_to_app_info_name_table(entry->app_name_key, entry);
+
+        if ( !add_entry_to_app_info_name_table(entry->app_name_key, entry) )
+        {
+            delete entry;
+            return nullptr;
+        }
     }
 
     return entry;
@@ -574,7 +579,8 @@ void AppInfoManager::init_appid_info_table(AppIdModuleConfig* mod_config)
         if ((app_id = get_static_app_info_entry(entry->payloadId)))
             app_info_payload_table[app_id] = entry;
 
-        add_entry_to_app_info_name_table(entry->app_name_key, entry);
+        if ( !add_entry_to_app_info_name_table(entry->app_name_key, entry) )
+            delete entry;
     }
     fclose(tableFile);
 
index ca292ccdab2d338e0a4a704c5626429f22fb22ab..624c4c8b95a2689e3d038348690aa4aaa8af67b4 100644 (file)
@@ -212,17 +212,21 @@ bool SideChannel::process(int max_messages)
     {
         // get message if one is available.
         ConnectorMsgHandle* handle = connector_receive->receive_message(false);
+
         // if none, we are complete
-        if ( handle == nullptr )
+        if ( !handle )
             break;
-        else
+
+        else if ( receive_handler )
         {
             SCMessage* msg = new SCMessage;
+
             // get the ConnectorMsg from the (at this point) abstract class
             ConnectorMsg* connector_msg = connector_receive->get_connector_msg(handle);
 
             msg->content = connector_msg->data;
             msg->content_length = connector_msg->length;
+
             // if the message is longer than the header, assume we have a header
             if ( connector_msg->length >= sizeof(SCMsgHdr) )
             {
@@ -234,15 +238,13 @@ bool SideChannel::process(int max_messages)
             }
 
             msg->handle = handle;   // link back to the underlying SCC message
-
             received_message = true;
 
-            if ( receive_handler != nullptr )
-                (receive_handler)(msg);
-
-            if ( (max_messages > 0) && (--max_messages == 0) )
-                break;
+            receive_handler(msg);
         }
+
+        if ( (max_messages > 0) && (--max_messages == 0) )
+            break;
     }
     return received_message;
 }