Squashed commit of the following:
commit
83d922a1dc71b2f874e32ed35d2692598b3bc31a
Author: Katura Harvey <katharve@cisco.com>
Date: Tue Jul 30 13:37:30 2019 -0400
http_inspect: remove 0-byte workaround
if ( flow->service and flow->clouseau and !p->is_cooked() )
bumble(p);
- if ( !p->dsize )
+ // For reassembled PDUs, a null data buffer signals no detection. Detection can be required
+ // with a length of 0. For raw packets, a length of 0 does signal no detection.
+ if ( (p->is_cooked() and !p->data) or (!p->is_cooked() and !p->dsize) )
DetectionEngine::disable_content(p);
else if ( flow->gadget && flow->gadget->likes(p) )
HttpEnums::SEC__NOT_COMPUTE };
int32_t num_head_lines[2] = { HttpEnums::STAT_NOT_PRESENT, HttpEnums::STAT_NOT_PRESENT };
bool tcp_close[2] = { false, false };
- bool zero_byte_workaround[2];
bool partial_flush[2] = { false, false };
// Infractions and events are associated with a specific message and are stored in the
return;
// Don't make pkt_data for headers available to detection
- // FIXIT-M One byte to avoid potential problems with zero
if ((session_data->section_type[source_id] == SEC_HEADER) ||
(session_data->section_type[source_id] == SEC_TRAILER))
{
- p->set_detect_limit(1);
+ p->set_detect_limit(0);
}
// Limit alt_dsize of message body sections to request/response depth
p->set_detect_limit(session_data->detect_depth_remaining[source_id]);
}
- const int remove_workaround = session_data->zero_byte_workaround[source_id] ? 1 : 0;
const bool partial_flush = session_data->partial_flush[source_id];
- if (!process(p->data, p->dsize - remove_workaround, p->flow, source_id, !partial_flush))
+ if (!process(p->data, p->dsize, p->flow, source_id, !partial_flush))
{
DetectionEngine::disable_content(p);
}
partial_buffer_length = buf_size;
}
- // FIXIT-M kludge until we work out issues with returning an empty buffer
http_buf.data = buffer;
- if (buf_size > 0)
- {
- http_buf.length = buf_size;
- session_data->zero_byte_workaround[source_id] = false;
- }
- else
- {
- buffer[0] = '\0';
- http_buf.length = 1;
- session_data->zero_byte_workaround[source_id] = true;
- }
+ http_buf.length = buf_size;
+
buffer = nullptr;
session_data->section_offset[source_id] = 0;
}
bytes_processed += flushed_bytes;
trs.sos.seglist_base_seq += flushed_bytes;
- if ( pdu->dsize )
+ if ( pdu->data )
{
if ( p->packet_flags & PKT_PDU_TAIL )
pdu->packet_flags |= ( PKT_REBUILT_STREAM | PKT_STREAM_EST | PKT_PDU_TAIL );