Merge pull request #913 from yskcg/fix_segment_fault_dev
Fix segment fault dev
This commit is contained in:
@@ -1099,7 +1099,7 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
|
||||
sizeof(flow->ssh_tls.client_requested_server_name), "%s",
|
||||
flow->ndpi_flow->protos.stun_ssl.ssl.client_requested_server_name);
|
||||
|
||||
if(flow->ndpi_flow->protos.stun_ssl.ssl.server_names_len > 0)
|
||||
if(flow->ndpi_flow->protos.stun_ssl.ssl.server_names_len > 0 && flow->ndpi_flow->protos.stun_ssl.ssl.server_names)
|
||||
flow->ssh_tls.server_names = ndpi_strdup(flow->ndpi_flow->protos.stun_ssl.ssl.server_names);
|
||||
flow->ssh_tls.notBefore = flow->ndpi_flow->protos.stun_ssl.ssl.notBefore;
|
||||
flow->ssh_tls.notAfter = flow->ndpi_flow->protos.stun_ssl.ssl.notAfter;
|
||||
|
||||
@@ -131,6 +131,10 @@ void *ndpi_realloc(void *ptr, size_t old_size, size_t new_size) {
|
||||
/* ****************************************** */
|
||||
|
||||
char *ndpi_strdup(const char *s) {
|
||||
if( s == NULL ){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int len = strlen(s);
|
||||
char *m = ndpi_malloc(len + 1);
|
||||
|
||||
|
||||
@@ -87,6 +87,14 @@ static void ndpi_int_someip_add_connection (struct ndpi_detection_module_struct
|
||||
NDPI_LOG_INFO(ndpi_struct, "found SOME/IP\n");
|
||||
}
|
||||
|
||||
static u_int32_t someip_data_cover_32(const u_int8_t *data)
|
||||
{
|
||||
u_int32_t value;
|
||||
|
||||
memcpy(&value,data,sizeof(u_int32_t));
|
||||
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* Dissector function that searches SOME/IP headers
|
||||
*/
|
||||
@@ -111,8 +119,8 @@ void ndpi_search_someip (struct ndpi_detection_module_struct *ndpi_struct,
|
||||
}
|
||||
|
||||
//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]));
|
||||
u_int32_t message_id = ntohl(someip_data_cover_32(&packet->payload[0]));
|
||||
u_int32_t request_id = ntohl(someip_data_cover_32(&packet->payload[8]));
|
||||
|
||||
NDPI_LOG_DBG2(ndpi_struct, "====>>>> SOME/IP Message ID: %08x [len: %u]\n",
|
||||
message_id, packet->payload_packet_len);
|
||||
@@ -125,7 +133,7 @@ void ndpi_search_someip (struct ndpi_detection_module_struct *ndpi_struct,
|
||||
//####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####
|
||||
|
||||
// we extract the remaining length
|
||||
u_int32_t someip_len = ntohl(*((u_int32_t *)&packet->payload[4]));
|
||||
u_int32_t someip_len = ntohl(someip_data_cover_32(&packet->payload[4]));
|
||||
if (packet->payload_packet_len != (someip_len + 8)) {
|
||||
NDPI_LOG_DBG(ndpi_struct, "Excluding SOME/IP .. Length field invalid!\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_SOMEIP);
|
||||
|
||||
Reference in New Issue
Block a user