aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/protocols/tftp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lib/protocols/tftp.c b/src/lib/protocols/tftp.c
index f5aa32e62..2366bbe1f 100644
--- a/src/lib/protocols/tftp.c
+++ b/src/lib/protocols/tftp.c
@@ -98,7 +98,8 @@ void ndpi_search_tftp(struct ndpi_detection_module_struct
{
ndpi_set_risk(ndpi_struct, flow, NDPI_MALFORMED_PACKET, "Invalid TFTP RR/WR header: Source/Destination file missing");
} else {
- memcpy(flow->protos.tftp.filename, &packet->payload[2], ndpi_min(filename_len, sizeof(flow->protos.tftp.filename) - 1));
+ filename_len = ndpi_min(filename_len, sizeof(flow->protos.tftp.filename) - 1);
+ memcpy(flow->protos.tftp.filename, &packet->payload[2], filename_len);
flow->protos.tftp.filename[filename_len] = '\0';
}