]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4789: http_param: fix memory management issue
authorDenys Zikratyi -X (dzikraty - SOFTSERVE INC at Cisco) <dzikraty@cisco.com>
Mon, 7 Jul 2025 14:46:15 +0000 (14:46 +0000)
committerRayen Mohanty (ramohant) <ramohant@cisco.com>
Mon, 7 Jul 2025 14:46:15 +0000 (14:46 +0000)
Merge in SNORT/snort3 from ~DZIKRATY/snort3:fix_http_param_2 to master

Squashed commit of the following:

commit 2a31c83bb0c0dea22e12f89f11d812e6067f5bc7
Author: Denys Zikratyi -X (dzikraty - SOFTSERVE INC at Cisco) <dzikraty@cisco.com>
Date:   Thu Jun 26 09:20:08 2025 -0400

    http_param: clear body http_param after each flush

src/service_inspectors/http_inspect/http_msg_body.cc
src/service_inspectors/http_inspect/http_msg_request.cc
src/service_inspectors/http_inspect/http_msg_request.h
src/service_inspectors/http_inspect/http_msg_section.cc

index 2f6ac57b5de9c72fe24d33ddd2f5e0c7057ba970..593350609332c2766fa52fc6b47ff6c1d0ea6d7f 100644 (file)
@@ -853,6 +853,9 @@ void HttpMsgBody::clear()
         session_data->partial_mime_last_complete[source_id] = last_attachment_complete;
     }
 
+    if (request != nullptr)
+        request->clear_body_params();
+        
     HttpMsgSection::clear();
 }
 
index 223fd97be605b14a97b8710aed032d28daef5f49..9d3275e39cc8d57f29d0828420a47581fdda1041 100644 (file)
@@ -211,6 +211,12 @@ ParameterMap& HttpMsgRequest::get_body_params()
     return *body_params;
 }
 
+void HttpMsgRequest::clear_body_params()
+{
+    if (body_params != nullptr)
+        body_params->clear();
+}
+
 void HttpMsgRequest::gen_events()
 {
     if (*transaction->get_infractions(source_id) & INF_BAD_REQ_LINE)
index 250024d56a25d1dfb34b9653f7fcc98cd950af00..5591e987654aeeae819e1cf169e33a682edfd011 100644 (file)
@@ -55,6 +55,7 @@ public:
     HttpUri* get_http_uri() { return uri; }
     ParameterMap& get_query_params();
     ParameterMap& get_body_params();
+    void clear_body_params();
 
     static bool is_webdav(HttpEnums::MethodId method)
     {
index 903697716a37d073d5c9a85aa2ca4ca93e1716a9..d1a5d3f9338a435ea8b6768bf1d0a63b51b8071b 100644 (file)
@@ -329,7 +329,7 @@ const Field& HttpMsgSection::get_param_buffer(Cursor& c, const HttpParam& param)
         const Field& rb = body->get_detect_data();
         const Field& nb = body->get_classic_client_body();
 
-        if (rb.length() > 0 && nb.length() > 0 && body->is_first())
+        if (rb.length() > 0 && nb.length() > 0)
         {
             HttpQueryParser parser(rb.start(), rb.length(),
                 nb.start(), nb.length(), uri_config,