]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2642 in SNORT/snort3 from ~THOPETER/snort3:h2i18 to master
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Wed, 25 Nov 2020 13:59:22 +0000 (13:59 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Wed, 25 Nov 2020 13:59:22 +0000 (13:59 +0000)
Squashed commit of the following:

commit fe4ebaed9bd43d59603aaee23890cbd7e3ae740e
Author: Tom Peters <thopeter@cisco.com>
Date:   Mon Nov 23 15:55:12 2020 -0500

    http2_inspect: HI error handling improvements

src/service_inspectors/http2_inspect/http2_flow_data.cc
src/service_inspectors/http2_inspect/http2_flow_data.h
src/service_inspectors/http2_inspect/http2_headers_frame.cc
src/service_inspectors/http2_inspect/http2_stream.h
src/service_inspectors/http_inspect/http_inspect.cc

index ef616fba3b6fc8fd8b29145128eeb39d8937cba7..c766a12b3da83cf4b5faee1c5ce730148ae2e3b3 100644 (file)
@@ -110,21 +110,6 @@ void Http2FlowData::set_hi_flow_data(HttpFlowData* flow)
     stream->set_hi_flow_data(flow);
 }
 
-HttpMsgSection* Http2FlowData::get_hi_msg_section() const
-{
-    Http2Stream* stream = get_hi_stream();
-    if (stream == nullptr)
-        return nullptr;
-    return stream->get_hi_msg_section();
-}
-
-void Http2FlowData::set_hi_msg_section(HttpMsgSection* section)
-{
-    assert(stream_in_hi != Http2Enums::NO_STREAM_ID);
-    Http2Stream* stream = get_hi_stream();
-    stream->set_hi_msg_section(section);
-}
-
 class Http2Stream* Http2FlowData::find_stream(uint32_t key) const
 {
     for (const StreamInfo& stream_info : streams)
index da25a60d4999af15e70c3af0d3cd3734e9c6f14e..2b2758eae4b2c119debf4fd94eb6fd66c0a87946 100644 (file)
@@ -60,8 +60,9 @@ public:
     // Used by http_inspect to store its stuff
     HttpFlowData* get_hi_flow_data() const;
     void set_hi_flow_data(HttpFlowData* flow);
-    HttpMsgSection* get_hi_msg_section() const;
-    void set_hi_msg_section(HttpMsgSection* section);
+    HttpMsgSection* get_hi_msg_section() const { return hi_msg_section; }
+    void set_hi_msg_section(HttpMsgSection* section)
+        { assert((hi_msg_section == nullptr) || (section == nullptr)); hi_msg_section = section; }
 
     friend class Http2Frame;
     friend class Http2DataFrame;
@@ -138,6 +139,7 @@ protected:
     // At any given time there may be different streams going in each direction. But only one of
     // them is the stream that http_inspect is actually processing at the moment.
     uint32_t stream_in_hi = Http2Enums::NO_STREAM_ID;
+    HttpMsgSection* hi_msg_section = nullptr;
 
     // Reassemble() data to eval()
     uint8_t lead_frame_header[2][Http2Enums::FRAME_HEADER_LENGTH];
index d11e4003644efc334f433140143e4b69def48c58..e600aba2fabaacfbe9fc008c6dff6348ee89ba9a 100644 (file)
@@ -104,7 +104,11 @@ void Http2HeadersFrame::process_decoded_headers(HttpFlowData* http_flow, SourceI
 
     // If this is a truncated headers frame, call http_inspect finish()
     if (session_data->is_processing_partial_header())
-        session_data->hi_ss[hi_source_id]->finish(session_data->flow);
+    {
+        const bool need_reassemble = session_data->hi_ss[hi_source_id]->finish(session_data->flow);
+        assert(need_reassemble);
+        UNUSED(need_reassemble);
+    }
 
     // http_inspect reassemble() of headers
     {
index d107267f6ac6d23e6c28189d598b4cbe15cd3efc..62070b6fca5575ef3194dde41f70b55063f75092 100644 (file)
@@ -43,8 +43,6 @@ public:
     const Field& get_buf(unsigned id);
     HttpFlowData* get_hi_flow_data() const { return hi_flow_data; }
     void set_hi_flow_data(HttpFlowData* flow_data);
-    HttpMsgSection* get_hi_msg_section() const { return hi_msg_section; }
-    void set_hi_msg_section(HttpMsgSection* section) { hi_msg_section = section; }
     uint32_t get_xtradata_mask() { return (current_frame != nullptr) ?
         current_frame->get_xtradata_mask() : 0; }
     Http2Frame *get_current_frame() { return current_frame; }
@@ -69,7 +67,6 @@ private:
     Http2FlowData* const session_data;
     Http2Frame* current_frame = nullptr;
     HttpFlowData* hi_flow_data = nullptr;
-    HttpMsgSection* hi_msg_section = nullptr;
     bool end_stream_on_data_flush[2] = { false, false };
     Http2Enums::StreamState state[2] =
         { Http2Enums::STREAM_EXPECT_HEADERS, Http2Enums::STREAM_EXPECT_HEADERS };
index 0241e3ccf19782f9efe65440cee592a07b09da05..e384cc0f0dc728574ed383cce9e9317d0deb4691 100755 (executable)
@@ -596,6 +596,7 @@ void HttpInspect::clear(Packet* p)
     if (h2i_flow_data != nullptr)
     {
         current_section = h2i_flow_data->get_hi_msg_section();
+        // assert(current_section != nullptr); // FIXIT-E fix H2I so that this is correct
         h2i_flow_data->set_hi_msg_section(nullptr);
     }
     else