aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoremanuele-f <faranda@ntop.org>2020-02-12 19:36:47 +0100
committeremanuele-f <faranda@ntop.org>2020-02-12 19:36:47 +0100
commit2efc09a20e6503d99fe3d76fcc16b1892fb7c7ff (patch)
tree86d0d2d1871f310c51ce1da993a2a80ea12b3376 /src
parent3fa61a394b7314e67c97888dd686ac84609a8b02 (diff)
Fix invalid memory read
Diffstat (limited to 'src')
-rw-r--r--src/lib/protocols/mail_smtp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/protocols/mail_smtp.c b/src/lib/protocols/mail_smtp.c
index f839598d6..045601f78 100644
--- a/src/lib/protocols/mail_smtp.c
+++ b/src/lib/protocols/mail_smtp.c
@@ -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);
}