From 81bc7825d112fdb37461be9414dcb6b1547cf547 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Tue, 28 Jan 2020 14:02:09 -0500 Subject: [PATCH] Potentially fixed strncpy warning by Coverity. --- code/Assbin/AssbinFileWriter.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/Assbin/AssbinFileWriter.cpp b/code/Assbin/AssbinFileWriter.cpp index daa748f6d..4bc8f7cac 100644 --- a/code/Assbin/AssbinFileWriter.cpp +++ b/code/Assbin/AssbinFileWriter.cpp @@ -795,13 +795,14 @@ public: Write(out, compressed); // == 20 bytes - char buff[256]; - strncpy(buff, pFile, 256); + char buff[256] = {0}; + ai_snprintf(buff, 256, "%s", pFile); out->Write(buff, sizeof(char), 256); - strncpy(buff, cmd, 128); + memset(buff, 0, sizeof(buff)); + ai_snprintf(buff, 128, "%s", cmd); out->Write(buff, sizeof(char), 128); - + // leave 64 bytes free for future extensions memset(buff, 0xcd, 64); out->Write(buff, sizeof(char), 64);