]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1238 in SNORT/snort3 from appid_reinspect to master
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Thu, 24 May 2018 17:11:05 +0000 (13:11 -0400)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Thu, 24 May 2018 17:11:05 +0000 (13:11 -0400)
Squashed commit of the following:

commit 28c121dd6a20db3d8c31d888815b98d0d6cec4a7
Author: Shravan Rangaraju <shrarang@cisco.com>
Date:   Thu May 24 18:46:03 2018 -0400

    appid: clean only HTTP data on HTTP reinspect

src/network_inspectors/appid/appid_http_session.cc
src/network_inspectors/appid/appid_http_session.h
src/network_inspectors/appid/appid_session.cc
src/network_inspectors/appid/appid_session.h
src/network_inspectors/appid/tp_appid_utils.cc

index b93504b2fd9836edb37272d67da79873356ceee2..2c0b03794f2db073f945d844b4f84051441b1b2b 100644 (file)
@@ -1037,3 +1037,89 @@ void AppIdHttpSession::reset_ptype_scan_counts()
     memset(ptype_scan_counts, 0, sizeof(ptype_scan_counts));
 }
 
+void AppIdHttpSession::clear_all_fields()
+{
+    if (host)
+    {
+        delete host;
+        host = nullptr;
+    }
+    if (url)
+    {
+        delete url;
+        url = nullptr;
+    }
+    if (uri)
+    {
+        delete uri;
+        uri = nullptr;
+    }
+    if (referer)
+    {
+        delete referer;
+        referer = nullptr;
+    }
+    if (useragent)
+    {
+        delete useragent;
+        useragent = nullptr;
+    }
+    if (via)
+    {
+        delete via;
+        via = nullptr;
+    }
+    if (cookie)
+    {
+        delete cookie;
+        cookie = nullptr;
+    }
+    if (body)
+    {
+        delete body;
+        body = nullptr;
+    }
+    if (response_code)
+    {
+        delete response_code;
+        response_code = nullptr;
+    }
+    if (content_type)
+    {
+        delete content_type;
+        content_type = nullptr;
+    }
+    if (location)
+    {
+        delete location;
+        location = nullptr;
+    }
+    if (req_body)
+    {
+        delete req_body;
+        req_body = nullptr;
+    }
+    if (server)
+    {
+        delete server;
+        server = nullptr;
+    }
+    if (x_working_with)
+    {
+        delete x_working_with;
+        x_working_with = nullptr;
+    }
+    if (xff_addr)
+    {
+        delete xff_addr;
+        xff_addr = nullptr;
+    }
+    if (xffPrecedence)
+    {
+        for (int i = 0; i < numXffFields; i++)
+            delete xffPrecedence[i];
+        delete xffPrecedence;
+        xffPrecedence = NULL;
+    }
+}
+
index a3fc3006c6c7f96dbfcf1a09f65223fd8b7bc750..44bfcc42e6bd8390c6e2c2f806910b8be2862c34 100644 (file)
@@ -224,6 +224,8 @@ public:
 
     virtual void custom_init() { }
 
+    void clear_all_fields();
+
 protected:
     void init_chp_match_descriptor(ChpMatchDescriptor& cmd);
     int initial_chp_sweep(ChpMatchDescriptor&);
index 7ccbf2728acc06028d3a63699729e4644bfa1322..ba20fe2a4addee1331058a6f9c1726e56e972cdb 100644 (file)
@@ -872,6 +872,12 @@ void AppIdSession::clear_http_flags()
     }
 }
 
+void AppIdSession::clear_http_data()
+{
+  if (!hsession) return;
+  hsession->clear_all_fields();
+}
+
 AppIdHttpSession* AppIdSession::get_http_session()
 {
     if ( !hsession )
index cff4c4444bc9f3c87454b42cbeb0ad60807f2e16..a5526c687af799c0762e9c47693e4e0c5dbcd177 100644 (file)
@@ -298,6 +298,7 @@ public:
 
     bool is_payload_appid_set();
     void clear_http_flags();
+    void clear_http_data();
     void reset_session_data();
 
     AppIdHttpSession* get_http_session();
index e05cc502de11aa4d833e27e8e2646b73600167d4..06c7acef6c851871a4afa448c26e0d60ad6f533b 100644 (file)
@@ -611,7 +611,7 @@ bool do_tp_discovery(AppIdSession& asd, IpProtocol protocol,
             if (appidDebug->is_active())
                 LogMessage("AppIdDbg %s 3rd party allow reinspect http\n",
                     appidDebug->get_debug_session());
-            asd.reset_session_data();
+            asd.clear_http_data();
         }
 
         if (!asd.is_tp_processing_done())