From: huica Date: Thu, 17 Sep 2015 18:55:57 +0000 (-0400) Subject: fix nhttp checks X-Git-Tag: 3.0.0-233~828^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c27bebc0dc45fdbacd3d51ddaa43749d98f882de;p=thirdparty%2Fsnort3.git fix nhttp checks --- diff --git a/src/mime/file_mime_process.cc b/src/mime/file_mime_process.cc index 455a4981c..0dfbd378d 100644 --- a/src/mime/file_mime_process.cc +++ b/src/mime/file_mime_process.cc @@ -42,20 +42,20 @@ #include "utils/util.h" #include "utils/snort_bounds.h" -typedef struct _MimeToken +struct MimeToken { const char* name; int name_len; int search_id; -} MimeToken; +} ; -typedef enum _MimeHdrEnum +enum MimeHdrEnum { HDR_CONTENT_TYPE = 0, HDR_CONT_TRANS_ENC, HDR_CONT_DISP, HDR_LAST -} MimeHdrEnum; +}; const MimeToken mime_hdrs[] = { @@ -65,18 +65,18 @@ const MimeToken mime_hdrs[] = { NULL, 0, 0 } }; -typedef struct _MIMESearch +struct MIMESearch { const char* name; int name_len; -} MIMESearch; +} ; -typedef struct _MIMESearchInfo +struct MIMESearchInfo { int id; int index; int length; -} MIMESearchInfo; +} ; MIMESearchInfo mime_search_info; @@ -498,7 +498,6 @@ void MimeSession::reset_mime_state() const uint8_t* MimeSession::process_mime_data_paf(Flow* flow, const uint8_t* start, const uint8_t* end, bool upload, FilePosition position) { - bool done_data = is_end_of_data(flow); /* if we've just entered the data state, check for a dot + end of line @@ -567,7 +566,6 @@ const uint8_t* MimeSession::process_mime_data_paf(Flow* flow, const uint8_t* sta return NULL; } - if (normalize_data(config, start, end) < 0) return NULL; /* now we shouldn't have to worry about copying any data to the alt buffer diff --git a/src/service_inspectors/nhttp_inspect/nhttp_msg_header.cc b/src/service_inspectors/nhttp_inspect/nhttp_msg_header.cc index ac17913cd..6bf44c042 100644 --- a/src/service_inspectors/nhttp_inspect/nhttp_msg_header.cc +++ b/src/service_inspectors/nhttp_inspect/nhttp_msg_header.cc @@ -24,6 +24,7 @@ #include "utils/util.h" #include "detection/detection_util.h" #include "file_api/file_service.h" +#include "file_api/file_flows.h" #include "nhttp_enum.h" #include "nhttp_msg_request.h" @@ -125,6 +126,10 @@ void NHttpMsgHeader::setup_file_processing() // fully supports it remove the outer if statement that prevents it from being done. if (session_data->file_depth_remaining[1-source_id] == 0) { + FileFlows* file_flows = FileFlows::get_file_flows(flow); + if (!file_flows) + return; + if ((session_data->file_depth_remaining[source_id] = FileService::get_max_file_depth()) < 0) { session_data->file_depth_remaining[source_id] = 0; diff --git a/src/service_inspectors/nhttp_inspect/nhttp_stream_splitter.cc b/src/service_inspectors/nhttp_inspect/nhttp_stream_splitter.cc index ce1f9144a..57606d779 100644 --- a/src/service_inspectors/nhttp_inspect/nhttp_stream_splitter.cc +++ b/src/service_inspectors/nhttp_inspect/nhttp_stream_splitter.cc @@ -496,7 +496,7 @@ bool NHttpStreamSplitter::finish(Flow* flow) if (file_flows) file_flows->file_process(nullptr, 0, SNORT_FILE_END, false, false); } - else if (session_data->mime_state != nullptr) + else { session_data->mime_state->process_mime_data(flow, nullptr, 0, true, SNORT_FILE_END);