Fix invalid memory read

This commit is contained in:
emanuele-f 2020-02-12 19:36:47 +01:00
parent 3fa61a394b
commit 2efc09a20e

View file

@ -153,8 +153,10 @@ 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);
if(out) {
snprintf(flow->protos.ftp_imap_pop_smtp.username,
sizeof(flow->protos.ftp_imap_pop_smtp.username), "%s", out);
size_t len = ndpi_min(out_len, sizeof(flow->protos.ftp_imap_pop_smtp.username) - 1);
memcpy(flow->protos.ftp_imap_pop_smtp.username, out, len);
flow->protos.ftp_imap_pop_smtp.username[len] = '\0';
ndpi_free(out);
}