From 81c649d62109208e458153325c609e134acf7948 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Thu, 30 Jul 2015 09:17:34 -0700 Subject: [PATCH] [PVS-Studio] Fix sprintf() security warnings Bug #301 --- source/Log.cpp | 2 +- source/Mockingboard.cpp | 4 ++-- source/SerialComms.cpp | 2 +- source/Speaker.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/Log.cpp b/source/Log.cpp index e277a56c..d8963ffe 100644 --- a/source/Log.cpp +++ b/source/Log.cpp @@ -57,5 +57,5 @@ void LogFileOutput(LPCTSTR format, ...) va_start(args, format); _vsntprintf(output, sizeof(output) - 1, format, args); - fprintf(g_fh, output); + fprintf(g_fh, "%s", output); } diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 590c7870..a0769cd5 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -826,7 +826,7 @@ static void MB_Update() double fTicksSecs = (double)GetTickCount() / 1000.0; sprintf(szDbg, "%010.3f: [MBUpdt] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X xxx\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); OutputDebugString(szDbg); - if (g_fh) fprintf(g_fh, szDbg); + if (g_fh) fprintf(g_fh, "%s", szDbg); dwByteOffset = dwCurrentWriteCursor; } @@ -839,7 +839,7 @@ static void MB_Update() double fTicksSecs = (double)GetTickCount() / 1000.0; sprintf(szDbg, "%010.3f: [MBUpdt] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X XXX\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); OutputDebugString(szDbg); - if (g_fh) fprintf(g_fh, szDbg); + if (g_fh) fprintf(g_fh, "%s", szDbg); dwByteOffset = dwCurrentWriteCursor; } diff --git a/source/SerialComms.cpp b/source/SerialComms.cpp index 77b55f91..88862b09 100644 --- a/source/SerialComms.cpp +++ b/source/SerialComms.cpp @@ -1045,7 +1045,7 @@ DWORD WINAPI CSuperSerialCard::CommThread(LPVOID lpParameter) sprintf(szDbg, "CommThread: Err=Other (0x%08X): InQueue=0x%08X, OutQueue=0x%08X\n", dwErrors, Stat.cbInQue, Stat.cbOutQue); OutputDebugString(szDbg); if (g_fh) - fprintf(g_fh, szDbg); + fprintf(g_fh, "%s", szDbg); } return -1; } diff --git a/source/Speaker.cpp b/source/Speaker.cpp index 3459cb93..10c7f282 100644 --- a/source/Speaker.cpp +++ b/source/Speaker.cpp @@ -886,7 +886,7 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples) double fTicksSecs = (double)GetTickCount() / 1000.0; sprintf(szDbg, "%010.3f: [Submit] PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X XXX\n", fTicksSecs, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamples); OutputDebugString(szDbg); - if (g_fh) fprintf(g_fh, szDbg); + if (g_fh) fprintf(g_fh, "%s", szDbg); dwByteOffset = dwCurrentWriteCursor; nNumSamplesError = 0;