]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2089 in SNORT/snort3 from ~NIHDESAI/snort3:tsan_mime to master
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Wed, 25 Mar 2020 19:40:43 +0000 (19:40 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Wed, 25 Mar 2020 19:40:43 +0000 (19:40 +0000)
Squashed commit of the following:

commit 60962397f8910eb4ade3ff842db5262d3337eeea
Author: Nihal Desai <nihdesai@cisco.com>
Date:   Wed Mar 18 04:57:26 2020 -0400

    mime: fix data race in mime config

src/mime/file_mime_config.cc
src/service_inspectors/http_inspect/http_inspect.cc
src/service_inspectors/http_inspect/http_inspect.h
src/service_inspectors/http_inspect/http_msg_header.cc
src/service_inspectors/http_inspect/http_msg_header.h

index 0ab391dd1f9a2642d74e36ba3382d30b1e5fbdae..aae828259de26c23c3feab235f944c771e1ab898 100644 (file)
@@ -131,8 +131,6 @@ void DecodeConfig::sync_all_depths()
 
 int DecodeConfig::get_max_depth(int decode_depth)
 {
-    sync_all_depths();
-
     if ( file_depth and decode_depth )
         return (file_depth > decode_depth) ? file_depth : decode_depth;
 
index 8d30233feafb5f2418fbf621b6d8d3fd75bac136..90ddd2331002bb59cffebf70de7d8b17d06e1e3a 100644 (file)
@@ -88,6 +88,8 @@ bool HttpInspect::configure(SnortConfig* )
     xtra_host_id = Stream::reg_xtra_data_cb(get_xtra_host);
     xtra_jsnorm_id = Stream::reg_xtra_data_cb(get_xtra_jsnorm);
 
+    config_decode();
+
     return true;
 }
 
@@ -440,7 +442,8 @@ bool HttpInspect::process(const uint8_t* data, const uint16_t dsize, Flow* const
         break;
     case SEC_HEADER:
         current_section = new HttpMsgHeader(
-            data, dsize, session_data, source_id, buf_owner, flow, params);
+            data, dsize, session_data, source_id, buf_owner, flow, params,
+            decode_conf);
         break;
     case SEC_BODY_CL:
         current_section = new HttpMsgBodyCl(
index ae62c44cb3879098d389e9a199e638c2ecdb6ebd..58ce5f2d494cfc132495b8022a0c95d5e7f8e118 100644 (file)
@@ -67,6 +67,7 @@ public:
     static int get_xtra_uri(snort::Flow*, uint8_t**, uint32_t*, uint32_t*);
     static int get_xtra_host(snort::Flow*, uint8_t** buf, uint32_t* len, uint32_t* type);
     static int get_xtra_jsnorm(snort::Flow*, uint8_t**, uint32_t*, uint32_t*);
+    void config_decode() { decode_conf.sync_all_depths(); }
 
 private:
     friend HttpApi;
@@ -84,6 +85,7 @@ private:
     static uint32_t xtra_uri_id;
     static uint32_t xtra_host_id;
     static uint32_t xtra_jsnorm_id;
+    snort::DecodeConfig decode_conf;
 };
 
 #endif
index 855c745072d6bdc07cf0322aab17730e7c42273d..ac2be52f4d9afd032ac3b738a83894d090aea4c1 100644 (file)
@@ -31,6 +31,7 @@
 #include "http_api.h"
 #include "http_common.h"
 #include "http_enum.h"
+#include "http_inspect.h"
 #include "http_msg_request.h"
 #include "http_msg_body.h"
 #include "pub_sub/http_events.h"
@@ -43,8 +44,9 @@ using namespace HttpEnums;
 
 HttpMsgHeader::HttpMsgHeader(const uint8_t* buffer, const uint16_t buf_size,
     HttpFlowData* session_data_, SourceId source_id_, bool buf_owner, Flow* flow_,
-    const HttpParaList* params_) :
-    HttpMsgHeadShared(buffer, buf_size, session_data_, source_id_, buf_owner, flow_, params_)
+    const HttpParaList* params_, DecodeConfig decode_conf_) :
+    HttpMsgHeadShared(buffer, buf_size, session_data_, source_id_, buf_owner, flow_, params_),
+    decode_conf(decode_conf_)
 {
     transaction->set_header(this, source_id);
     get_related_sections();
index ce9c7a7d27783f75a77d58a1e53bfcc4477b5654..16663d5bf5e0221a8d4af40188745eedffa71d87 100644 (file)
@@ -36,7 +36,7 @@ class HttpMsgHeader : public HttpMsgHeadShared
 public:
     HttpMsgHeader(const uint8_t* buffer, const uint16_t buf_size, HttpFlowData* session_data_,
         HttpCommon::SourceId source_id_, bool buf_owner, snort::Flow* flow_,
-        const HttpParaList* params_);
+        const HttpParaList* params_, snort::DecodeConfig decode_conf);
     HttpEnums::InspectSection get_inspection_section() const override
         { return HttpEnums::IS_HEADER; }
     bool detection_required() const override { return true; }