From fa4d654a01a979073a597174b3980e6595dae832 Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Tue, 9 Mar 2021 10:54:10 +0000 Subject: [PATCH] Fix potential mime type detection bug in IRC/FTP file_transferred event The files framework uses strncpy to copy data into the buffer that is used for IRC/FTP mime type detection. From all I can tell that means that, in these cases, currently mime type detection will be messed up if the data being passed in contains zero bytes. --- src/analyzer/protocol/file/File.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analyzer/protocol/file/File.cc b/src/analyzer/protocol/file/File.cc index 6324246cbe..63b1a61193 100644 --- a/src/analyzer/protocol/file/File.cc +++ b/src/analyzer/protocol/file/File.cc @@ -25,7 +25,7 @@ void File_Analyzer::DeliverStream(int len, const u_char* data, bool orig) if ( n ) { - strncpy(buffer + buffer_len, (const char*) data, n); + memcpy(buffer + buffer_len, (const char*) data, n); buffer_len += n; if ( buffer_len == BUFFER_SIZE )