From c220db01281564bf5b50575ee7e24b38e45f5050 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 14 Jul 2014 17:41:09 +0200 Subject: Static Code Analysis : Generalize the use of Safe String functions. Add some NULL pointer checks. Avoid false-positive detection in AppendMenu (MF_SEPARATOR) calls by setting the last parameter to "" instead of NULL. --- src/Common/Random.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Common/Random.c') diff --git a/src/Common/Random.c b/src/Common/Random.c index c897e3b7..445e8f24 100644 --- a/src/Common/Random.c +++ b/src/Common/Random.c @@ -12,6 +12,7 @@ #include "Tcdefs.h" #include "Crc.h" #include "Random.h" +#include static unsigned __int8 buffer[RNG_POOL_SIZE]; static unsigned char *pRandPool = NULL; @@ -576,10 +577,10 @@ BOOL SlowPoll (void) char dllPath[MAX_PATH]; if (GetSystemDirectory (dllPath, MAX_PATH)) { - strcat(dllPath, "\\NETAPI32.DLL"); + StringCbCatA(dllPath, sizeof(dllPath), "\\NETAPI32.DLL"); } else - strcpy(dllPath, "C:\\Windows\\System32\\NETAPI32.DLL"); + StringCbCopyA(dllPath, sizeof(dllPath), "C:\\Windows\\System32\\NETAPI32.DLL"); hNetAPI32 = LoadLibrary (dllPath); if (hNetAPI32 != NULL) @@ -630,7 +631,7 @@ BOOL SlowPoll (void) char szDevice[24]; /* Check whether we can access this device */ - sprintf (szDevice, "\\\\.\\PhysicalDrive%d", nDrive); + StringCbPrintfA (szDevice, sizeof(szDevice), "\\\\.\\PhysicalDrive%d", nDrive); hDevice = CreateFile (szDevice, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hDevice == INVALID_HANDLE_VALUE) -- cgit v1.2.3