void HttpMsgBody::do_utf_decoding(const Field&, Field&) {}
void HttpMsgBody::do_file_decompression(const Field&, Field&) {}
void HttpMsgBody::do_enhanced_js_normalization(const Field&, Field&) {}
-void HttpMsgBody::clean_partial(uint32_t&, uint32_t&, uint8_t*&, uint32_t&, int32_t) {}
+void HttpMsgBody::clean_partial(uint32_t&, uint32_t&, uint8_t*&, uint32_t&) {}
void HttpMsgBody::bookkeeping_regular_flush(uint32_t&, uint8_t*&, uint32_t&, int32_t) {}
#ifdef REG_TEST
void HttpMsgBody::print_body_section(FILE*, const char*) {}
}
void HttpMsgBody::clean_partial(uint32_t& partial_inspected_octets, uint32_t& partial_detect_length,
- uint8_t*& partial_detect_buffer, uint32_t& partial_js_detect_length, int32_t detect_length)
+ uint8_t*& partial_detect_buffer, uint32_t& partial_js_detect_length)
{
body_octets += msg_text.length();
partial_inspected_octets = session_data->partial_flush[source_id] ? msg_text.length() : 0;
if (session_data->detect_depth_remaining[source_id] > 0)
{
delete[] partial_detect_buffer;
- assert(detect_length <= session_data->detect_depth_remaining[source_id]);
+ const int32_t detect_length =
+ (partial_js_detect_length <= session_data->detect_depth_remaining[source_id]) ?
+ partial_js_detect_length : session_data->detect_depth_remaining[source_id];
bookkeeping_regular_flush(partial_detect_length, partial_detect_buffer,
partial_js_detect_length, detect_length);
}
decompressed_file_body.length());
cumulative_data.set(total_length, cumulative_buffer, true);
do_legacy_js_normalization(cumulative_data, js_norm_body);
- if ((int32_t)partial_js_detect_length == js_norm_body.length())
+ // Partial inspections don't update detect_depth_remaining.
+ // If there is no new data or same data will be sent to detection because
+ // we already reached detect_depth, don't do another detection
+ if ((int32_t)partial_js_detect_length == js_norm_body.length() ||
+ partial_js_detect_length >= session_data->detect_depth_remaining[source_id])
{
clean_partial(partial_inspected_octets, partial_detect_length,
- partial_detect_buffer, partial_js_detect_length, js_norm_body.length());
+ partial_detect_buffer, partial_js_detect_length);
return;
}
}
void do_enhanced_js_normalization(const Field& input, Field& output);
void do_legacy_js_normalization(const Field& input, Field& output);
void clean_partial(uint32_t& partial_inspected_octets, uint32_t& partial_detect_length,
- uint8_t*& partial_detect_buffer, uint32_t& partial_js_detect_length,
- int32_t detect_length);
+ uint8_t*& partial_detect_buffer, uint32_t& partial_js_detect_length);
void bookkeeping_regular_flush(uint32_t& partial_detect_length,
uint8_t*& partial_detect_buffer, uint32_t& partial_js_detect_length,
int32_t detect_length);