From 4e6dda6361087161d3c6ba317393421d34b9e50f Mon Sep 17 00:00:00 2001 From: dillinger79 Date: Wed, 18 Jan 2017 18:21:47 +0100 Subject: [PATCH 1/2] Update smpp.c --- src/lib/protocols/smpp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/protocols/smpp.c b/src/lib/protocols/smpp.c index ff64c47e5..d6d898893 100644 --- a/src/lib/protocols/smpp.c +++ b/src/lib/protocols/smpp.c @@ -31,6 +31,11 @@ static void ndpi_int_smpp_add_connection(struct ndpi_detection_module_struct* nd ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SMPP, NDPI_PROTOCOL_UNKNOWN); } +static u_int8_t ndpi_check_overflow(u_int32_t current_legth, u_int32_t total_lenth) +{ + return (current_legth > 0 && current_legth > INT_MAX - total_lenth); +} + void ndpi_search_smpp_tcp(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) { @@ -68,8 +73,8 @@ void ndpi_search_smpp_tcp(struct ndpi_detection_module_struct* ndpi_struct, while(total_pdu_l < packet->payload_packet_len) { // get next PDU length tmp_pdu_l = ntohl(get_u_int32_t(packet->payload, total_pdu_l)); - // if zero, return, will try the next TCP segment - if(tmp_pdu_l == 0) return; + // if zero or overflowing , return, will try the next TCP segment + if(tmp_pdu_l == 0 || ndpi_check_overflow(tmp_pdu_l, total_pdu_l) ) return; // inc total PDU length total_pdu_l += ntohl(get_u_int32_t(packet->payload, total_pdu_l)); // inc total PDU count From 8aa1d770f0e6a2c2cde5feff3bb337e295f53e1e Mon Sep 17 00:00:00 2001 From: dillinger79 Date: Wed, 18 Jan 2017 18:27:56 +0100 Subject: [PATCH 2/2] Add files via upload this pcap file causes a busy loop --- tests/pcap/smpp_piggypack.pcap | Bin 0 -> 144 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/pcap/smpp_piggypack.pcap diff --git a/tests/pcap/smpp_piggypack.pcap b/tests/pcap/smpp_piggypack.pcap new file mode 100644 index 0000000000000000000000000000000000000000..636cd75e36abf2f4824ceeab9c0dc6a4fccbc4b2 GIT binary patch literal 144 zcmca|c+)~A1{MY+z{m*X7?*N6aBSma$N;iI7#VOdxH2$AO-OZMa9~?wR?on|2*UCX z8~o~{W<}Pky-;nCsQ;g51{7rE;F8bg{szK86NDQW;8t-N8Z-R=|NkwL5VxTT0|3#w B8Ych% literal 0 HcmV?d00001