VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Volumes.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-07-14 17:41:09 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-11-08 23:21:27 +0100
commitc220db01281564bf5b50575ee7e24b38e45f5050 (patch)
tree5e66aa935ec029ca2bac6fa282f4c18710fc2d0d /src/Common/Volumes.c
parentc01f392a7ba1d5cdd4aa182eeb273cf41717d94f (diff)
downloadVeraCrypt-c220db01281564bf5b50575ee7e24b38e45f5050.tar.gz
VeraCrypt-c220db01281564bf5b50575ee7e24b38e45f5050.zip
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.
Diffstat (limited to 'src/Common/Volumes.c')
-rw-r--r--src/Common/Volumes.c14
1 files changed, 10 insertions, 4 deletions
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 <Strsafe.h>
+#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)