From: Mike Stepanek (mstepane) Date: Wed, 25 Nov 2020 13:59:22 +0000 (+0000) Subject: Merge pull request #2642 in SNORT/snort3 from ~THOPETER/snort3:h2i18 to master X-Git-Tag: 3.0.3-6~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e81bcfe49de614c4963f58ba961977fb3022ec7c;p=thirdparty%2Fsnort3.git Merge pull request #2642 in SNORT/snort3 from ~THOPETER/snort3:h2i18 to master Squashed commit of the following: commit fe4ebaed9bd43d59603aaee23890cbd7e3ae740e Author: Tom Peters Date: Mon Nov 23 15:55:12 2020 -0500 http2_inspect: HI error handling improvements --- diff --git a/src/service_inspectors/http2_inspect/http2_flow_data.cc b/src/service_inspectors/http2_inspect/http2_flow_data.cc index ef616fba3..c766a12b3 100644 --- a/src/service_inspectors/http2_inspect/http2_flow_data.cc +++ b/src/service_inspectors/http2_inspect/http2_flow_data.cc @@ -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) diff --git a/src/service_inspectors/http2_inspect/http2_flow_data.h b/src/service_inspectors/http2_inspect/http2_flow_data.h index da25a60d4..2b2758eae 100644 --- a/src/service_inspectors/http2_inspect/http2_flow_data.h +++ b/src/service_inspectors/http2_inspect/http2_flow_data.h @@ -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]; diff --git a/src/service_inspectors/http2_inspect/http2_headers_frame.cc b/src/service_inspectors/http2_inspect/http2_headers_frame.cc index d11e40036..e600aba2f 100644 --- a/src/service_inspectors/http2_inspect/http2_headers_frame.cc +++ b/src/service_inspectors/http2_inspect/http2_headers_frame.cc @@ -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 { diff --git a/src/service_inspectors/http2_inspect/http2_stream.h b/src/service_inspectors/http2_inspect/http2_stream.h index d107267f6..62070b6fc 100644 --- a/src/service_inspectors/http2_inspect/http2_stream.h +++ b/src/service_inspectors/http2_inspect/http2_stream.h @@ -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 }; diff --git a/src/service_inspectors/http_inspect/http_inspect.cc b/src/service_inspectors/http_inspect/http_inspect.cc index 0241e3ccf..e384cc0f0 100755 --- a/src/service_inspectors/http_inspect/http_inspect.cc +++ b/src/service_inspectors/http_inspect/http_inspect.cc @@ -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