Fix memory invalid access in SMTP and leaks in TLS
This commit is contained in:
@@ -143,7 +143,7 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
u_char *out;
|
u_char *out;
|
||||||
size_t out_len;
|
size_t out_len;
|
||||||
|
|
||||||
ndpi_user_pwd_payload_copy(buf, sizeof(buf)-1, 0,
|
ndpi_user_pwd_payload_copy(buf, sizeof(buf), 0,
|
||||||
packet->line[a].ptr, packet->line[a].len);
|
packet->line[a].ptr, packet->line[a].len);
|
||||||
|
|
||||||
#ifdef SMTP_DEBUG
|
#ifdef SMTP_DEBUG
|
||||||
@@ -176,8 +176,11 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
out = ndpi_base64_decode((const u_char*)buf, (size_t)strlen((const char*)buf), &out_len);
|
out = ndpi_base64_decode((const u_char*)buf, (size_t)strlen((const char*)buf), &out_len);
|
||||||
|
|
||||||
if(out) {
|
if(out) {
|
||||||
snprintf(flow->protos.ftp_imap_pop_smtp.password,
|
size_t len = ndpi_min(out_len, sizeof(flow->protos.ftp_imap_pop_smtp.password) - 1);
|
||||||
sizeof(flow->protos.ftp_imap_pop_smtp.password), "%s", out);
|
|
||||||
|
memcpy(flow->protos.ftp_imap_pop_smtp.password, out, len);
|
||||||
|
flow->protos.ftp_imap_pop_smtp.password[len] = '\0';
|
||||||
|
|
||||||
ndpi_free(out);
|
ndpi_free(out);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -483,8 +483,12 @@ static int processTLSBlock(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0b: /* Certificate */
|
case 0x0b: /* Certificate */
|
||||||
processCertificate(ndpi_struct, flow);
|
/* Important: populate the tls union fields only after
|
||||||
flow->l4.tcp.tls.certificate_processed = 1;
|
* ndpi_int_tls_add_connection has been called */
|
||||||
|
if(flow->l4.tcp.tls.hello_processed) {
|
||||||
|
processCertificate(ndpi_struct, flow);
|
||||||
|
flow->l4.tcp.tls.certificate_processed = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user