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/Volumes.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Common/Volumes.c') diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c index 506a4d04..15ee8fe6 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -33,6 +33,9 @@ #include "Volumes.h" #include "Pkcs5.h" +#ifdef _WIN32 +#include +#endif /* Volume header v5 structure (used since TrueCrypt 7.0): */ // @@ -187,6 +190,9 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, PCR } else { + if (!retInfo) + return ERR_PARAMETER_INCORRECT; + cryptoInfo = *retInfo = crypto_open (); if (cryptoInfo == NULL) return ERR_OUTOFMEMORY; @@ -934,16 +940,16 @@ int CreateVolumeHeaderInMemory (BOOL bBoot, char *header, int ea, int mode, Pass for (i = 0; i < j; i++) { char tmp2[8] = {0}; - sprintf (tmp2, "%02X", (int) (unsigned char) keyInfo.master_keydata[i + primaryKeyOffset]); - strcat (MasterKeyGUIView, tmp2); + StringCbPrintfA (tmp2, sizeof(tmp2), "%02X", (int) (unsigned char) keyInfo.master_keydata[i + primaryKeyOffset]); + StringCbCatA (MasterKeyGUIView, sizeof(MasterKeyGUIView), tmp2); } HeaderKeyGUIView[0] = 0; for (i = 0; i < NBR_KEY_BYTES_TO_DISPLAY; i++) { char tmp2[8]; - sprintf (tmp2, "%02X", (int) (unsigned char) dk[primaryKeyOffset + i]); - strcat (HeaderKeyGUIView, tmp2); + StringCbPrintfA (tmp2, sizeof(tmp2), "%02X", (int) (unsigned char) dk[primaryKeyOffset + i]); + StringCbCatA (HeaderKeyGUIView, sizeof(HeaderKeyGUIView), tmp2); } if (dots3) -- cgit v1.2.3