aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/someip.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2017-10-08 18:55:40 +0200
committerLuca Deri <deri@ntop.org>2017-10-08 18:55:40 +0200
commit2476c3c1b63b87ae85254f717315b9f8a52b4f7e (patch)
treefe659aee67fe9f5fd61b4d9a095443961f63707c /src/lib/protocols/someip.c
parented830d24747dba810712156d9e05be0b3a811235 (diff)
Fixed bug in someip dissector (access out of boundary)
Fixed memory leak in ndpiReader
Diffstat (limited to 'src/lib/protocols/someip.c')
-rw-r--r--src/lib/protocols/someip.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/protocols/someip.c b/src/lib/protocols/someip.c
index 714648417..93dfa50ae 100644
--- a/src/lib/protocols/someip.c
+++ b/src/lib/protocols/someip.c
@@ -90,26 +90,28 @@ static void ndpi_int_someip_add_connection (struct ndpi_detection_module_struct
void ndpi_search_someip (struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
-
+ const struct ndpi_packet_struct *packet = &flow->packet;
+
+ if (packet->payload_packet_len < 16) {
+ NDPI_LOG(NDPI_PROTOCOL_SOMEIP, ndpi_struct, NDPI_LOG_DEBUG,
+ "Excluding SOME/IP .. mandatory header not found (not enough data for all fields)\n");
+ NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_SOMEIP);
+ return;
+ }
+
//####Maybe check carrier protocols?####
NDPI_LOG(NDPI_PROTOCOL_SOMEIP, ndpi_struct, NDPI_LOG_DEBUG, "SOME/IP search called...\n");
- const struct ndpi_packet_struct *packet = &flow->packet;
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) {
return;
}
-
+
//we extract the Message ID and Request ID and check for special cases later
u_int32_t message_id = ntohl(*((u_int32_t *)&packet->payload[0]));
u_int32_t request_id = ntohl(*((u_int32_t *)&packet->payload[8]));
NDPI_LOG(NDPI_PROTOCOL_SOMEIP, ndpi_struct, NDPI_LOG_DEBUG, "====>>>> SOME/IP Message ID: %08x [len: %u]\n",
message_id, packet->payload_packet_len);
- if (packet->payload_packet_len < 16) {
- NDPI_LOG(NDPI_PROTOCOL_SOMEIP, ndpi_struct, NDPI_LOG_DEBUG, "Excluding SOME/IP .. mandatory header not found (not enough data for all fields)\n");
- NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_SOMEIP);
- return;
- }
//####Maximum packet size in SOMEIP depends on the carrier protocol, and I'm not certain how well enforced it is, so let's leave that for round 2####