enip: avoid quadratic complexity with multiple service packet

Ticket: 8757
pull/16213/head
Philippe Antoine 3 months ago committed by Victor Julien
parent 8e95600253
commit 0c1ec09879

@ -235,6 +235,12 @@ pub fn parse_cip_reqresp_multiple(
let mut size_list = Vec::new();
let mut rem = i;
for j in 0..nb as usize {
// require offsets list to be strictly increasing
// Avoid having multiple times the same offset,
// and reparsing the same expensive structure quadratically
if (offset_list[j] as usize) < start.len() - rem.len() {
return Err(nom8::Err::Error(make_error(i, ErrorKind::Satisfy)));
}
if (offset_list[j] as usize) < start.len() {
let (rem2, packet) = parse_cip_multi(&start[offset_list[j] as usize..])?;
packet_list.push(packet);

Loading…
Cancel
Save