diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-02-08 23:42:50 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-02-09 11:01:18 +0100 |
commit | 608e86c7bc962f369003d9d05d4402f9da273f0c (patch) | |
tree | 8128401b0f6c7b052a7e1476e6876e44e8a3334b /src | |
parent | 516da2229d66232f8c6ad84f5fecbdfc8c8f9f67 (diff) | |
download | VeraCrypt-608e86c7bc962f369003d9d05d4402f9da273f0c.tar.gz VeraCrypt-608e86c7bc962f369003d9d05d4402f9da273f0c.zip |
Static Code Analysis: solve issues in Expander. Use real random values for wipe buffers.
Diffstat (limited to 'src')
-rw-r--r-- | src/ExpandVolume/ExpandVolume.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c index 53ad7ce3..65a3740a 100644 --- a/src/ExpandVolume/ExpandVolume.c +++ b/src/ExpandVolume/ExpandVolume.c @@ -288,6 +288,7 @@ int QueryVolumeInfo (HWND hwndDlg, const char *lpszVolume, uint64 * pHostSizeFre break; case EV_FS_TYPE_FAT: *pSizeLimitFS = 4 * BYTES_PER_GB - 1; + break; default: *pSizeLimitFS = (uint64)-1; } @@ -410,7 +411,7 @@ int ExtendFileSystem (HWND hwndDlg , char *lpszVolume, Password *pVolumePassword if ( !GetFileSystemType(rootPath,&fs) ) { dwError = GetLastError(); - if (dwError = ERROR_UNRECOGNIZED_VOLUME) + if (dwError == ERROR_UNRECOGNIZED_VOLUME) { // raw volume with unrecognized file system -> return with no error nStatus = ERR_SUCCESS; @@ -517,6 +518,8 @@ static int ExpandVolume (HWND hwndDlg, char *lpszVolume, Password *pVolumePasswo BOOL bTimeStampValid = FALSE; LARGE_INTEGER headerOffset; BOOL backupHeader; + byte *wipeBuffer = NULL; + uint32 workChunkSize = TC_VOLUME_HEADER_GROUP_SIZE; if (pVolumePassword->Length == 0) return -1; @@ -858,16 +861,22 @@ static int ExpandVolume (HWND hwndDlg, char *lpszVolume, Password *pVolumePasswo /* wipe old backup header */ if ( !cryptoInfo->LegacyVolume ) - { - byte *wipeBuffer = NULL; + { byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT]; byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT]; byte wipePass; - uint32 workChunkSize = TC_VOLUME_HEADER_GROUP_SIZE; UINT64_STRUCT unitNo; LARGE_INTEGER offset; WipeAlgorithmId wipeAlgorithm = TC_WIPE_35_GUTMANN; + if ( !RandgetBytes (hwndDlg, wipeRandChars, TC_WIPE_RAND_CHAR_COUNT, TRUE)
+ || !RandgetBytes (hwndDlg, wipeRandCharsUpdate, TC_WIPE_RAND_CHAR_COUNT, TRUE)
+ )
+ { + nStatus = ERR_OS_ERROR; + goto error; + } + DebugAddProgressDlgStatus(hwndDlg, "Wiping old backup header ...\r\n"); wipeBuffer = (byte *) TCalloc (workChunkSize); @@ -911,11 +920,21 @@ static int ExpandVolume (HWND hwndDlg, char *lpszVolume, Password *pVolumePasswo // we don't check FlushFileBuffers() return code, because it fails for devices // (same implementation in password.c - a bug or not ???) } + + burn (wipeRandChars, TC_WIPE_RAND_CHAR_COUNT); + burn (wipeRandCharsUpdate, TC_WIPE_RAND_CHAR_COUNT); } error: dwError = GetLastError (); + if (wipeBuffer) + { + burn (wipeBuffer, workChunkSize); + TCfree (wipeBuffer); + wipeBuffer = NULL; + } + burn (buffer, sizeof (buffer)); if (cryptoInfo != NULL) |