"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/service_inspectors/http2_inspect/http2_stream.cc" between
snort3-3.1.36.0.tar.gz and snort3-3.1.38.0.tar.gz

About: Snort 3 is a network intrusion prevention and detection system (IDS/IPS) combining the benefits of signature, protocol and anomaly-based inspection.

http2_stream.cc  (snort3-3.1.36.0):http2_stream.cc  (snort3-3.1.38.0)
skipping to change at line 31 skipping to change at line 31
#include "config.h" #include "config.h"
#endif #endif
#include "http2_enum.h" #include "http2_enum.h"
#include "http2_stream.h" #include "http2_stream.h"
#include "service_inspectors/http_inspect/http_flow_data.h" #include "service_inspectors/http_inspect/http_flow_data.h"
#include "service_inspectors/http_inspect/http_stream_splitter.h" #include "service_inspectors/http_inspect/http_stream_splitter.h"
#include "http2_data_cutter.h" #include "http2_data_cutter.h"
#include "http2_dummy_packet.h"
#include "http2_flow_data.h" #include "http2_flow_data.h"
using namespace snort;
using namespace HttpCommon; using namespace HttpCommon;
using namespace Http2Enums; using namespace Http2Enums;
Http2Stream::Http2Stream(uint32_t stream_id_, Http2FlowData* session_data_) : Http2Stream::Http2Stream(uint32_t stream_id_, Http2FlowData* session_data_) :
stream_id(stream_id_), stream_id(stream_id_),
session_data(session_data_) session_data(session_data_)
{ {
} }
Http2Stream::~Http2Stream() Http2Stream::~Http2Stream()
{ {
delete current_frame; delete current_frame;
delete hi_flow_data; delete hi_flow_data;
} }
void Http2Stream::eval_frame(const uint8_t* header_buffer, uint32_t header_len, void Http2Stream::eval_frame(const uint8_t* header_buffer, uint32_t header_len,
const uint8_t* data_buffer, uint32_t data_len, SourceId source_id) const uint8_t* data_buffer, uint32_t data_len, SourceId source_id, Packet* p )
{ {
assert(current_frame == nullptr); assert(current_frame == nullptr);
current_frame = Http2Frame::new_frame(header_buffer, header_len, data_buffer , current_frame = Http2Frame::new_frame(header_buffer, header_len, data_buffer ,
data_len, session_data, source_id, this); data_len, session_data, source_id, this);
if (!session_data->abort_flow[source_id] && (get_state(source_id) != STREAM_ ERROR)) if (!session_data->abort_flow[source_id] && (get_state(source_id) != STREAM_ ERROR))
{ {
if (current_frame->valid_sequence(state[source_id])) if (current_frame->valid_sequence(state[source_id]))
{ {
current_frame->analyze_http1(); current_frame->analyze_http1(p);
current_frame->update_stream_state(); current_frame->update_stream_state();
} }
else else
{ {
set_state(source_id, STREAM_ERROR); set_state(source_id, STREAM_ERROR);
} }
} }
} }
// check if stream is completed, do cleanup if it is // check if stream is completed, do cleanup if it is
skipping to change at line 83 skipping to change at line 83
{ {
if (hi_flow_data != nullptr) if (hi_flow_data != nullptr)
{ {
delete hi_flow_data; delete hi_flow_data;
hi_flow_data = nullptr; hi_flow_data = nullptr;
} }
session_data->delete_stream = true; session_data->delete_stream = true;
} }
} }
void Http2Stream::clear_frame() void Http2Stream::clear_frame(Packet* p)
{ {
assert(current_frame != nullptr); assert(current_frame != nullptr);
current_frame->clear(); current_frame->clear(p);
delete current_frame; delete current_frame;
current_frame = nullptr; current_frame = nullptr;
check_and_cleanup_completed(); check_and_cleanup_completed();
} }
void Http2Stream::set_state(HttpCommon::SourceId source_id, StreamState new_stat e) void Http2Stream::set_state(HttpCommon::SourceId source_id, StreamState new_stat e)
{ {
assert((STREAM_EXPECT_HEADERS <= new_state) && (new_state <= STREAM_ERROR)); assert((STREAM_EXPECT_HEADERS <= new_state) && (new_state <= STREAM_ERROR));
assert(state[source_id] < new_state); assert(state[source_id] < new_state);
skipping to change at line 133 skipping to change at line 133
bool Http2Stream::is_open(HttpCommon::SourceId source_id) bool Http2Stream::is_open(HttpCommon::SourceId source_id)
{ {
return (state[source_id] == STREAM_EXPECT_BODY) || (state[source_id] == STRE AM_BODY); return (state[source_id] == STREAM_EXPECT_BODY) || (state[source_id] == STRE AM_BODY);
} }
// Caller must set session_data->stream_in_hi before calling this // Caller must set session_data->stream_in_hi before calling this
void Http2Stream::finish_msg_body(HttpCommon::SourceId source_id, bool expect_tr ailers, void Http2Stream::finish_msg_body(HttpCommon::SourceId source_id, bool expect_tr ailers,
bool clear_partial_buffer) bool clear_partial_buffer)
{ {
uint32_t http_flush_offset = 0; uint32_t http_flush_offset = 0;
Http2DummyPacket dummy_pkt;
dummy_pkt.flow = session_data->flow;
const H2BodyState body_state = expect_trailers ? const H2BodyState body_state = expect_trailers ?
H2_BODY_COMPLETE_EXPECT_TRAILERS : H2_BODY_COMPLETE; H2_BODY_COMPLETE_EXPECT_TRAILERS : H2_BODY_COMPLETE;
get_hi_flow_data()->finish_h2_body(source_id, body_state, clear_partial_buff er); get_hi_flow_data()->finish_h2_body(source_id, body_state, clear_partial_buff er);
if (clear_partial_buffer) if (clear_partial_buffer)
{ {
uint32_t unused = 0; const StreamSplitter::Status scan_result = session_data->hi_ss[source_id
const snort::StreamSplitter::Status scan_result = session_data->hi_ss[so ]->scan(
urce_id]->scan( session_data->flow, nullptr, 0, &http_flush_offset);
&dummy_pkt, nullptr, 0, unused, &http_flush_offset); assert(scan_result == StreamSplitter::FLUSH);
assert(scan_result == snort::StreamSplitter::FLUSH);
UNUSED(scan_result); UNUSED(scan_result);
} }
} }
 End of changes. 8 change blocks. 
12 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)