From b59af1451471c96be06c42284867c0e5c5bc5e65 Mon Sep 17 00:00:00 2001 From: probonopd Date: Sun, 17 Nov 2024 18:30:39 +0000 Subject: [PATCH] Remove compiler warnings net/ftpworker.cpp: In member function 'bool CFTPWorker::_ZN10CFTPWorker4PortEPKc.part.0(const char*)': net/ftpworker.cpp:466:9: warning: 'char* strncpy(char*, const char*, size_t)' specified bound 512 equals destination size [-Wstringop-truncation] 466 | strncpy(Buffer, pArgs, sizeof(Buffer)); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ net/ftpworker.cpp: In member function 'const TDirectoryListEntry* CFTPWorker::BuildDirectoryList(size_t&) const': net/ftpworker.cpp:365:11: warning: 'char* strncpy(char*, const char*, size_t)' specified bound 6 equals destination size [-Wstringop-truncation] 365 | strncpy(VolumeName, VolumeNames[i], sizeof(VolumeName)); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../Synth_Dexed/src/dexed.cpp: In member function 'void Dexed::setName(char*)': ../Synth_Dexed/src/dexed.cpp:1699:10: warning: 'char* strncpy(char*, const char*, size_t)' output may be truncated copying 10 bytes from a string of length 155 [-Wstringop-truncation] 1699 | strncpy(name, (char*)&data[DEXED_VOICE_OFFSET + DEXED_NAME], 10); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/net/ftpworker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/ftpworker.cpp b/src/net/ftpworker.cpp index e912b33..6f19f8a 100644 --- a/src/net/ftpworker.cpp +++ b/src/net/ftpworker.cpp @@ -362,7 +362,7 @@ const TDirectoryListEntry* CFTPWorker::BuildDirectoryList(size_t& nOutEntries) c for (size_t i = 0; i < nVolumes; ++i) { char VolumeName[6]; - strncpy(VolumeName, VolumeNames[i], sizeof(VolumeName)); + strncpy(VolumeName, VolumeNames[i], sizeof(VolumeName) - 1); strcat(VolumeName, ":"); // Returns FR_ @@ -463,7 +463,7 @@ bool CFTPWorker::Port(const char* pArgs) return false; char Buffer[TextBufferSize]; - strncpy(Buffer, pArgs, sizeof(Buffer)); + strncpy(Buffer, pArgs, sizeof(Buffer) - 1); if (m_pDataSocket != nullptr) {