Minor UA handling improvement to avoid heap-overflow
This commit is contained in:
@@ -347,7 +347,7 @@ int http_process_user_agent(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
flow->http.user_agent = ndpi_malloc(len);
|
||||
if(flow->http.user_agent) {
|
||||
strncpy(flow->http.user_agent, (char*)ua_ptr, ua_ptr_len);
|
||||
memcpy(flow->http.user_agent, (char*)ua_ptr, ua_ptr_len);
|
||||
flow->http.user_agent[ua_ptr_len] = '\0';
|
||||
|
||||
ndpi_check_user_agent(ndpi_struct, flow, flow->http.user_agent);
|
||||
|
||||
@@ -1128,15 +1128,19 @@ static void process_chlo(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if (ua_found)
|
||||
return;
|
||||
}
|
||||
if((memcmp(tag, "UAID", 4) == 0) &&
|
||||
(tag_offset_start + prev_offset + len < crypto_data_len)) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "UA: [%.*s]\n", len, &crypto_data[tag_offset_start + prev_offset]);
|
||||
|
||||
http_process_user_agent(ndpi_struct, flow,
|
||||
&crypto_data[tag_offset_start + prev_offset], len);
|
||||
ua_found = 1;
|
||||
if (sni_found)
|
||||
return;
|
||||
if(memcmp(tag, "UAID", 4) == 0) {
|
||||
u_int uaid_offset = tag_offset_start + prev_offset;
|
||||
|
||||
if((uaid_offset + len) < crypto_data_len) {
|
||||
NDPI_LOG_DBG2(ndpi_struct, "UA: [%.*s]\n", len, &crypto_data[uaid_offset]);
|
||||
|
||||
http_process_user_agent(ndpi_struct, flow, &crypto_data[uaid_offset], len); /* http.c */
|
||||
ua_found = 1;
|
||||
|
||||
if (sni_found)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
prev_offset = offset;
|
||||
|
||||
Reference in New Issue
Block a user