Skip to content

Commit

Permalink
CIP: fix infinite-loop (#2295)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanNardi authored Feb 1, 2024
1 parent 8fbef7f commit 1321271
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/protocols/cip.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ static void ndpi_search_cip(struct ndpi_detection_module_struct *ndpi_struct,
) {
u_int8_t num_items = packet->payload[0], offset = 2;

while((num_items > 0) && (packet->payload_packet_len > (offset + 4))) {
while((num_items > 0) && (packet->payload_packet_len > ((u_int32_t)offset + 4))) {
// u_int16_t type_id = *((u_int16_t*)&packet->payload[offset]);
u_int16_t lenght = (packet->payload[offset+3] << 8) + packet->payload[offset+2];

offset += 4 + lenght;
num_items--;
}

if(offset == packet->payload_packet_len) {
Expand Down

0 comments on commit 1321271

Please sign in to comment.