diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-08-16 04:04:31 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-08-16 10:04:07 +0200 |
commit | ce76957a10070c132a8adfbe2e7d3f12395b4caa (patch) | |
tree | df9ede22756dc23ff9e19555ccfba1c3db62cc77 | |
parent | 1bf219b0dca05edf337b322162169209cd224b6c (diff) | |
download | VeraCrypt-ce76957a10070c132a8adfbe2e7d3f12395b4caa.tar.gz VeraCrypt-ce76957a10070c132a8adfbe2e7d3f12395b4caa.zip |
Windows: Fix various issues detected by static analysis.
-rw-r--r-- | src/Common/BootEncryption.cpp | 9 | ||||
-rw-r--r-- | src/Common/XZip.cpp | 2 | ||||
-rw-r--r-- | src/Crypto/GostCipher.c | 26 | ||||
-rw-r--r-- | src/Crypto/GostCipher.h | 6 | ||||
-rw-r--r-- | src/Crypto/Streebog.c | 4 | ||||
-rw-r--r-- | src/Crypto/cpu.c | 2 | ||||
-rw-r--r-- | src/Format/Tcformat.c | 16 | ||||
-rw-r--r-- | src/Mount/Mount.c | 2 |
8 files changed, 37 insertions, 30 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 3b799d04..984402dc 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -166,85 +166,86 @@ namespace VeraCrypt static void GetFileSize (const wstring &filePath, unsigned __int64* pSize) { Elevate(); DWORD result; CComBSTR fileBstr; BSTR bstr = W2BSTR(filePath.c_str()); if (bstr) { fileBstr.Attach (bstr); result = ElevatedComInstance->GetFileSize (fileBstr, pSize); } else { result = ERROR_OUTOFMEMORY; } if (result != ERROR_SUCCESS) { SetLastError (result); throw SystemException(SRC_POS); } } static BOOL DeviceIoControl (BOOL readOnly, BOOL device, const wstring &filePath, DWORD dwIoControlCode, LPVOID input, DWORD inputSize, LPVOID output, DWORD outputSize) { Elevate(); DWORD result; BSTR bstr = W2BSTR(filePath.c_str()); if (bstr) { CComBSTR inputBstr; + CComBSTR fileBstr; + fileBstr.Attach (bstr); + if (input && inputBstr.AppendBytes ((const char *) input, inputSize) != S_OK) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; } CComBSTR outputBstr; if (output && outputBstr.AppendBytes ((const char *) output, outputSize) != S_OK) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; } - CComBSTR fileBstr; - fileBstr.Attach (bstr); result = ElevatedComInstance->DeviceIoControl (readOnly, device, fileBstr, dwIoControlCode, inputBstr, &outputBstr); if (output) memcpy (output, *(void **) &outputBstr, outputSize); } else { result = ERROR_OUTOFMEMORY; } if (result != ERROR_SUCCESS) { SetLastError (result); return FALSE; } else return TRUE; } static BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly) { Elevate(); return ElevatedComInstance->IsPagingFileActive (checkNonWindowsPartitionsOnly); } static void WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value) { Elevate(); DWORD result; CComBSTR keyPathBstr, valueNameBstr; BSTR bstr = W2BSTR(keyPath); if (bstr) { keyPathBstr.Attach (bstr); @@ -2039,70 +2040,72 @@ namespace VeraCrypt // Write unmodified values char* xml = configContent; char key[128], value[2048]; while (xml && (xml = XmlFindElement (xml, "config"))) { XmlGetAttributeText (xml, "key", key, sizeof (key)); XmlGetNodeText (xml, value, sizeof (value)); fwprintf (configFile, L"\n\t\t<config key=\"%hs\">%hs</config>", key, value); xml++; } fputws (L"\n\t</configuration>", configFile); XmlWriteFooter (configFile); TCFlushFile (configFile); bRet = CheckFileStreamWriteErrors (hwnd, configFile, fileName); fclose (configFile); if (configContent != NULL) { burn (configContent, size); free (configContent); } return bRet; } static const wchar_t* EfiVarGuid = L"{8BE4DF61-93CA-11D2-AA0D-00E098032B8C}"; EfiBoot::EfiBoot() { ZeroMemory(EfiBootPartPath, sizeof(EfiBootPartPath)); ZeroMemory (systemPartitionPath, sizeof (systemPartitionPath)); + ZeroMemory (&sdn, sizeof (sdn)); + ZeroMemory (&partInfo, sizeof (partInfo)); m_bMounted = false; } void EfiBoot::MountBootPartition(WCHAR letter) { NTSTATUS res; ULONG len; memset(tempBuf, 0, sizeof(tempBuf)); // Load NtQuerySystemInformation function point if (!NtQuerySystemInformationPtr) { NtQuerySystemInformationPtr = (NtQuerySystemInformationFn) GetProcAddress (GetModuleHandle (L"ntdll.dll"), "NtQuerySystemInformation"); if (!NtQuerySystemInformationPtr) throw SystemException (SRC_POS); } res = NtQuerySystemInformationPtr((SYSTEM_INFORMATION_CLASS)SYSPARTITIONINFORMATION, tempBuf, sizeof(tempBuf), &len); if (res != S_OK) { SetLastError (res); throw SystemException (SRC_POS); } PUNICODE_STRING pStr = (PUNICODE_STRING) tempBuf; memcpy (systemPartitionPath, pStr->Buffer, min (pStr->Length, (sizeof (systemPartitionPath) - 2))); if (!letter) { if (!GetFreeDriveLetter(&EfiBootPartPath[0])) { throw ErrorException(L"No free letter to mount EFI boot partition", SRC_POS); } } else { EfiBootPartPath[0] = letter; } EfiBootPartPath[1] = ':'; EfiBootPartPath[2] = 0; @@ -2256,71 +2259,71 @@ namespace VeraCrypt memcpy(pVar, &partInfo.Gpt.PartitionId, 16); pVar += 16; // MbrType *(byte *)pVar = 0x02; pVar += sizeof(byte); // SigType *(byte *)pVar = 0x02; pVar += sizeof(byte); // Type and sub type 04 04 (file path) *(uint16 *)pVar = 0x0404; pVar += sizeof(uint16); // SizeOfFilePath ((CHAR16)FullPath.length + sizeof(EndOfrecord marker) ) *(uint16 *)pVar = (uint16)(execPath.length() * 2 + 2 + sizeof(uint32)); pVar += sizeof(uint16); // FilePath for (uint32 i = 0; i < execPath.length(); i++) { *(uint16 *)pVar = execPath[i]; pVar += sizeof(uint16); } *(uint16 *)pVar = 0; pVar += sizeof(uint16); // EndOfrecord *(uint32 *)pVar = 0x04ff7f; pVar += sizeof(uint32); // Set variable wchar_t varName[256]; StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum); SetFirmwareEnvironmentVariable(varName, EfiVarGuid, startVar, varSize); - delete startVar; + delete [] startVar; // Update order wstring order = L"Order"; order.insert(0, type == NULL ? L"Boot" : type); uint32 startOrderLen = GetFirmwareEnvironmentVariable(order.c_str(), EfiVarGuid, tempBuf, sizeof(tempBuf)); uint32 startOrderNumPos = UINT_MAX; bool startOrderUpdate = false; uint16* startOrder = (uint16*)tempBuf; for (uint32 i = 0; i < startOrderLen / 2; i++) { if (startOrder[i] == statrtOrderNum) { startOrderNumPos = i; break; } } // Create new entry if absent if (startOrderNumPos == UINT_MAX) { for (uint32 i = startOrderLen / 2; i > 0; --i) { startOrder[i] = startOrder[i - 1]; } startOrder[0] = statrtOrderNum; startOrderLen += 2; startOrderUpdate = true; } else if (startOrderNumPos > 0) { for (uint32 i = startOrderNumPos; i > 0; --i) { startOrder[i] = startOrder[i - 1]; } startOrder[0] = statrtOrderNum; startOrderUpdate = true; } if (startOrderUpdate) { SetFirmwareEnvironmentVariable(order.c_str(), EfiVarGuid, startOrder, startOrderLen); } diff --git a/src/Common/XZip.cpp b/src/Common/XZip.cpp index 9ce6de5d..be6d27ef 100644 --- a/src/Common/XZip.cpp +++ b/src/Common/XZip.cpp @@ -654,71 +654,71 @@ public: unsigned lookahead; // number of valid bytes ahead in window unsigned max_chain_length; // To speed up deflation, hash chains are never searched beyond this length. // A higher limit improves compression ratio but degrades the speed. unsigned int max_lazy_match; // Attempt to find a better match only when the current match is strictly // smaller than this value. This mechanism is used only for compression // levels >= 4. unsigned good_match; // Use a faster search when the previous match is longer than this int nice_match; // Stop searching when current match exceeds this }; typedef struct iztimes { __time32_t atime,mtime,ctime; } iztimes; // access, modify, create times typedef struct zlist { ush vem, ver, flg, how; // See central header in zipfile.c for what vem..off are ulg tim, crc, siz, len; extent nam, ext, cext, com; // offset of ext must be >= LOCHEAD ush dsk, att, lflg; // offset of lflg must be >= LOCHEAD ulg atx, off; char name[MAX_PATH]; // File name in zip file char *extra; // Extra field (set only if ext != 0) char *cextra; // Extra in central (set only if cext != 0) char *comment; // Comment (set only if com != 0) char iname[MAX_PATH]; // Internal file name after cleanup char zname[MAX_PATH]; // External version of internal name int mark; // Marker for files to operate on - int trash; // Marker for files to delete + // int trash; // Marker for files to delete int dosflag; // Set to force MSDOS file attributes struct zlist far *nxt; // Pointer to next header in list } TZipFileInfo; class TState; typedef unsigned (*READFUNC)(TState &state, char *buf,unsigned size); typedef unsigned (*FLUSHFUNC)(void *param, const char *buf, unsigned *size); typedef unsigned (*WRITEFUNC)(void *param, const char *buf, unsigned size); class TState { public: TState() //+++1.2 { param = 0; level = 0; seekable = FALSE; readfunc = 0; flush_outbuf = 0; err = 0; } void *param; int level; bool seekable; READFUNC readfunc; FLUSHFUNC flush_outbuf; TTreeState ts; TBitState bs; TDeflateState ds; const char *err; }; void Assert(TState &state,bool cond, const char *msg) diff --git a/src/Crypto/GostCipher.c b/src/Crypto/GostCipher.c index a745210f..ec09bddf 100644 --- a/src/Crypto/GostCipher.c +++ b/src/Crypto/GostCipher.c @@ -43,83 +43,83 @@ byte S_TC26[8][16] = { 0x5, 0xd, 0xf, 0x6, 0x9, 0x2, 0xc, 0xa, 0xb, 0x7, 0x8, 0x1, 0x4, 0x3, 0xe, 0x0 }, { 0x8, 0xe, 0x2, 0x5, 0x6, 0x9, 0x1, 0xc, 0xf, 0x4, 0xb, 0x0, 0xd, 0xa, 0x3, 0x7 }, { 0x1, 0x7, 0xe, 0xd, 0x0, 0x5, 0x8, 0x3, 0x4, 0xf, 0xa, 0x6, 0x9, 0xc, 0xb, 0x2 }, }; void gost_prepare_kds(gost_kds* kds) { uint32 i; // Build substitution tables. for (i = 0; i < 256; ++i) { uint32 p; p = kds->sbox[7][i >> 4] << 4 | kds->sbox[6][i & 15]; p = p << 24; p = p << 11 | p >> 21; kds->sbox_cvt[i] = p; // S87 p = kds->sbox[5][i >> 4] << 4 | kds->sbox[4][i & 15]; p = p << 16; p = p << 11 | p >> 21; kds->sbox_cvt[256 + i] = p; // S65 p = kds->sbox[3][i >> 4] << 4 | kds->sbox[2][i & 15]; p = p << 8; p = p << 11 | p >> 21; kds->sbox_cvt[256 * 2 + i] = p; // S43 p = kds->sbox[1][i >> 4] << 4 | kds->sbox[0][i & 15]; p = p << 11 | p >> 21; kds->sbox_cvt[256 * 3 + i] = p; // S21 } } #ifdef GOST_DYNAMIC_SBOXES static void xor_s_box(byte s_box[8][16], byte *seed) { int i; for (i = 0; i < 16; i++) { - s_box[1][i] ^= (seed[ (i * 4) + 0 ] ) & 0xF; - s_box[2][i] ^= (seed[ (i * 4) + 0 ]>>4) & 0xF; - s_box[3][i] ^= (seed[ (i * 4) + 1 ] ) & 0xF; - s_box[4][i] ^= (seed[ (i * 4) + 1 ]>>4) & 0xF; - s_box[5][i] ^= (seed[ (i * 4) + 2 ] ) & 0xF; - s_box[6][i] ^= (seed[ (i * 4) + 2 ]>>4) & 0xF; - s_box[7][i] ^= (seed[ (i * 4) + 3 ] ) & 0xF; - s_box[8][i] ^= (seed[ (i * 4) + 3 ]>>4) & 0xF; + s_box[0][i] ^= (seed[ (i * 4) + 0 ] ) & 0xF; + s_box[1][i] ^= (seed[ (i * 4) + 0 ]>>4) & 0xF; + s_box[2][i] ^= (seed[ (i * 4) + 1 ] ) & 0xF; + s_box[3][i] ^= (seed[ (i * 4) + 1 ]>>4) & 0xF; + s_box[4][i] ^= (seed[ (i * 4) + 2 ] ) & 0xF; + s_box[5][i] ^= (seed[ (i * 4) + 2 ]>>4) & 0xF; + s_box[6][i] ^= (seed[ (i * 4) + 3 ] ) & 0xF; + s_box[7][i] ^= (seed[ (i * 4) + 3 ]>>4) & 0xF; } } #endif -void gost_set_key(byte *key, gost_kds *ks) +void gost_set_key(const byte *key, gost_kds *ks) { #ifdef GOST_DYNAMIC_SBOXES STREEBOG_CTX sctx; byte sbox_seed[64]; #if defined (DEVICE_DRIVER) && !defined (_WIN64) KFLOATING_SAVE floatingPointState; NTSTATUS saveStatus = STATUS_SUCCESS; if (HasSSE2() || HasSSE41()) saveStatus = KeSaveFloatingPointState (&floatingPointState); #endif #endif memcpy(ks->key, key, GOST_KEYSIZE); memcpy(ks->sbox, S_TC26, sizeof(ks->sbox)); #ifdef GOST_DYNAMIC_SBOXES //Generate pseudorandom data based on the key STREEBOG_init(&sctx); STREEBOG_add(&sctx, key, 32); STREEBOG_finalize(&sctx, sbox_seed); #if defined (DEVICE_DRIVER) && !defined (_WIN64) if (NT_SUCCESS (saveStatus) && (HasSSE2() || HasSSE41())) KeRestoreFloatingPointState (&floatingPointState); #endif xor_s_box(ks->sbox, sbox_seed); #endif gost_prepare_kds(ks); } static uint32 f(uint32 v, uint32* sbox){ byte* x =(byte*) &v; /* Do substitutions */ @@ -196,74 +196,74 @@ void gost_decrypt_block(uint64 in_, uint64* out_, gost_kds* kds) { n2 ^= f(n1+key[6], sbox); n1 ^= f(n2+key[7], sbox); n2 ^= f(n1+key[7], sbox); n1 ^= f(n2+key[6], sbox); n2 ^= f(n1+key[5], sbox); n1 ^= f(n2+key[4], sbox); n2 ^= f(n1+key[3], sbox); n1 ^= f(n2+key[2], sbox); n2 ^= f(n1+key[1], sbox); n1 ^= f(n2+key[0], sbox); n2 ^= f(n1+key[7], sbox); n1 ^= f(n2+key[6], sbox); n2 ^= f(n1+key[5], sbox); n1 ^= f(n2+key[4], sbox); n2 ^= f(n1+key[3], sbox); n1 ^= f(n2+key[2], sbox); n2 ^= f(n1+key[1], sbox); n1 ^= f(n2+key[0], sbox); n2 ^= f(n1+key[7], sbox); n1 ^= f(n2+key[6], sbox); n2 ^= f(n1+key[5], sbox); n1 ^= f(n2+key[4], sbox); n2 ^= f(n1+key[3], sbox); n1 ^= f(n2+key[2], sbox); n2 ^= f(n1+key[1], sbox); n1 ^= f(n2+key[0], sbox); out[0] = n2; out[1] = n1; } #if defined(_M_AMD64) -void gost_encrypt_128_CBC_asm(byte *in, byte *out, gost_kds *ks, uint64 count); -void gost_decrypt_128_CBC_asm(byte *in, byte *out, gost_kds *ks, uint64 count); +void gost_encrypt_128_CBC_asm(const byte *in, byte *out, gost_kds *ks, uint64 count); +void gost_decrypt_128_CBC_asm(const byte *in, byte *out, gost_kds *ks, uint64 count); #endif -void gost_encrypt(byte *in, byte *out, gost_kds *ks, int count) { +void gost_encrypt(const byte *in, byte *out, gost_kds *ks, int count) { #if defined(_M_AMD64) gost_encrypt_128_CBC_asm(in, out, ks, (uint64)count); #else while (count > 0) { // encrypt two blocks in CBC mode gost_encrypt_block(*((uint64*)in), (uint64*)out, ks); *((gst_udword*)(out + 8)) = *((gst_udword*)(in + 8)) ^ *((gst_udword*)(out)); *((gst_udword*)(out + 12)) = *((gst_udword*)(in + 12)) ^ *((gst_udword*)(out + 4)); gost_encrypt_block(*((uint64*)(out + 8)), (uint64*)(out + 8), ks); count--; in += 16; out += 16; } #endif } -void gost_decrypt(byte *in, byte *out, gost_kds *ks, int count) { +void gost_decrypt(const byte *in, byte *out, gost_kds *ks, int count) { #if defined(_M_AMD64) gost_decrypt_128_CBC_asm(in, out, ks, (uint64)count); #else while (count > 0) { // decrypt two blocks in CBC mode gost_decrypt_block(*((uint64*)(in + 8)), (uint64*)(out + 8), ks); *((gst_udword*)(out + 8)) ^= *((gst_udword*)(in));; *((gst_udword*)(out + 12)) ^= *((gst_udword*)(in + 4));; gost_decrypt_block(*((uint64*)(in)), (uint64*)(out), ks); count--; in += 16; out += 16; } #endif } #endif
\ No newline at end of file diff --git a/src/Crypto/GostCipher.h b/src/Crypto/GostCipher.h index 9b9e18b4..35c6537c 100644 --- a/src/Crypto/GostCipher.h +++ b/src/Crypto/GostCipher.h @@ -17,45 +17,45 @@ #define GOST_BLOCKSIZE 8 #define GOST_SBOX_SIZE 16 //Production setting, but can be turned off to compare the algorithm with other implementations #define CIPHER_GOST89 #define GOST_DYNAMIC_SBOXES #if defined(CIPHER_GOST89) #ifndef rotl32 #define rotl32(b, shift) ((b << shift) | (b >> (32 - shift))) #endif typedef unsigned char byte; #ifdef GST_WINDOWS_BOOT typedef int gst_word; typedef long gst_dword; typedef unsigned int gst_uword; typedef unsigned long gst_udword; #else typedef short gst_word; typedef int gst_dword; typedef unsigned short gst_uword; typedef unsigned int gst_udword; #endif typedef struct gost_kds { byte key[32]; gst_udword sbox_cvt[256 * 4]; byte sbox[8][16]; } gost_kds; #define GOST_KS (sizeof(gost_kds)) -void gost_encrypt(byte *in, byte *out, gost_kds *ks, int count); -void gost_decrypt(byte *in, byte *out, gost_kds *ks, int count); -void gost_set_key(byte *key, gost_kds *ks); +void gost_encrypt(const byte *in, byte *out, gost_kds *ks, int count); +void gost_decrypt(const byte *in, byte *out, gost_kds *ks, int count); +void gost_set_key(const byte *key, gost_kds *ks); #else #define GOST_KS (0) #endif #endif diff --git a/src/Crypto/Streebog.c b/src/Crypto/Streebog.c index 9430bfa3..d13d58d2 100644 --- a/src/Crypto/Streebog.c +++ b/src/Crypto/Streebog.c @@ -2296,73 +2296,73 @@ g(unsigned long long *h, const unsigned long long *N, const unsigned char *m) Ki[4] = data[4];Ki[5] = data[5];Ki[6] = data[6];Ki[7] = data[7]; XLPS((Ki), ((const unsigned long long *) m), (data)); for (i = 0; i < 11; i++) ROUND(i, (Ki), (data)); XLPS((Ki), (C[11]), (Ki)); X((Ki), (data), (data)); /* E() done */ X((data), h, (data)); X((data), ((const unsigned long long *) m), h); } } static void stage2(STREEBOG_CTX *CTX, const unsigned char *data) { g((CTX->h), (CTX->N), data); add512((CTX->N), buffer512, (CTX->N)); add512((CTX->Sigma), (const unsigned long long *) data, (CTX->Sigma)); } static void stage3(STREEBOG_CTX *CTX) { ALIGN(16) unsigned long long buf[8]; memset(buf, 0x00, sizeof buf); memcpy(buf, (CTX->buffer), CTX->bufsize); memcpy((CTX->buffer), buf, 8 * sizeof (unsigned long long)); memset(buf, 0x00, sizeof buf); #ifndef __GOST3411_BIG_ENDIAN__ - buf[0] = CTX->bufsize << 3; + buf[0] = ((unsigned long long) CTX->bufsize) << 3; #else - buf[0] = BSWAP64(CTX->bufsize << 3); + buf[0] = BSWAP64(((unsigned long long) CTX->bufsize) << 3); #endif pad(CTX); g((CTX->h), (CTX->N), (const unsigned char *) (CTX->buffer)); add512((CTX->N), buf, (CTX->N)); add512((CTX->Sigma), (const unsigned long long *) CTX->buffer, (CTX->Sigma)); g((CTX->h), buffer0, (const unsigned char *) (CTX->N)); g((CTX->h), buffer0, (const unsigned char *) (CTX->Sigma)); memcpy((CTX->hash), (CTX->h), 8 * sizeof(unsigned long long)); } void STREEBOG_add(STREEBOG_CTX *CTX, byte *data, size_t len) { size_t chunksize; while (len > 63 && CTX->bufsize == 0) { stage2(CTX, data); data += 64; len -= 64; } while (len) { chunksize = 64 - CTX->bufsize; if (chunksize > len) chunksize = len; memcpy(&CTX->buffer[CTX->bufsize], data, chunksize); diff --git a/src/Crypto/cpu.c b/src/Crypto/cpu.c index c358088d..35fd36fe 100644 --- a/src/Crypto/cpu.c +++ b/src/Crypto/cpu.c @@ -247,71 +247,71 @@ static int TryAESNI () static int Detect_MS_HyperV_AES () { int hasAesNI = 0; // when Hyper-V is enabled on older versions of Windows Server (i.e. 2008 R2), the AES-NI capability // gets masked out for all applications, even running on the host. // We try to detect Hyper-V virtual CPU and perform a dummy AES-NI operation to check its real presence uint32 cpuid[4]; char HvProductName[13]; CpuId(0x40000000, cpuid); memcpy (HvProductName, &cpuid[1], 12); HvProductName[12] = 0; if (_stricmp(HvProductName, "Microsoft Hv") == 0) { #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KFLOATING_SAVE floatingPointState; if (NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))) { #endif hasAesNI = TryAESNI (); #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KeRestoreFloatingPointState (&floatingPointState); } #endif } return hasAesNI; } #endif void DetectX86Features() { - uint32 cpuid[4], cpuid1[4]; + uint32 cpuid[4] = {0}, cpuid1[4] = {0}; if (!CpuId(0, cpuid)) return; if (!CpuId(1, cpuid1)) return; g_hasMMX = (cpuid1[3] & (1 << 23)) != 0; if ((cpuid1[3] & (1 << 26)) != 0) g_hasSSE2 = TrySSE2(); g_hasAVX = g_hasSSE2 && (cpuid1[2] & (1 << 28)); g_hasSSE42 = g_hasSSE2 && (cpuid1[2] & (1 << 20)); g_hasSSE41 = g_hasSSE2 && (cpuid1[2] & (1 << 19)); g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9)); g_hasAESNI = g_hasSSE2 && (cpuid1[2] & (1<<25)); g_hasCLMUL = g_hasSSE2 && (cpuid1[2] & (1<<1)); #if !defined (_UEFI) && ((defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE) // Hypervisor = bit 31 of ECX of CPUID leaf 0x1 // reference: http://artemonsecurity.com/vmde.pdf if (!g_hasAESNI && (cpuid1[2] & (1<<31))) { g_hasAESNI = Detect_MS_HyperV_AES (); } #endif if ((cpuid1[3] & (1 << 25)) != 0) g_hasISSE = 1; else { uint32 cpuid2[4]; CpuId(0x080000000, cpuid2); if (cpuid2[0] >= 0x080000001) { CpuId(0x080000001, cpuid2); g_hasISSE = (cpuid2[3] & (1 << 22)) != 0; } diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 31140fd7..66ec3ac3 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -9174,82 +9174,84 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) } else { Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg); exit(0); } break; case CommandResumeSysEncLogOn: // Same as csysenc but passed only by the system (from the startup sequence) // From now on, we should be the only instance of the TC wizard allowed to deal with system encryption if (CreateSysEncMutex ()) { bDirectSysEncMode = TRUE; bDirectSysEncModeCommand = SYSENC_COMMAND_STARTUP_SEQ_RESUME; ChangeWizardMode (WIZARD_MODE_SYS_DEVICE); } else { Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg); exit(0); } break; case CommandEncDev: // Resume process of creation of a non-sys-device-hosted volume (passed by Wizard when the user needs to UAC-elevate) DirectDeviceEncMode = TRUE; break; case CommandInplaceDec: // Start (not resume) decrypting the specified non-system volume in place { wchar_t szTmp [TC_MAX_PATH + 8000] = {0}; - GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp)); - - if (wcslen (szTmp) < 1) + if ((HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp))) + && (wcslen (szTmp) >= 1) + ) { - // No valid volume path specified as command-line parameter - AbortProcess ("ERR_PARAMETER_INCORRECT"); - } - memset (szFileName, 0, sizeof (szFileName)); StringCbCopyW (szFileName, sizeof (szFileName), szTmp); DirectNonSysInplaceDecStartMode = TRUE; } + else + { + // No valid volume path specified as command-line parameter + AbortProcess ("ERR_PARAMETER_INCORRECT"); + } + } break; case CommandResumeInplace: // Resume interrupted process of non-system in-place encryption of a partition DirectNonSysInplaceEncResumeMode = TRUE; break; case CommandResumeInplaceDec: // Resume interrupted process of non-system in-place decryption of a partition DirectNonSysInplaceDecResumeMode = TRUE; break; case CommandResumeNonSysInplaceLogOn: // Ask the user whether to resume interrupted process of non-system in-place encryption of a partition // This switch is passed only by the system (from the startup sequence). DirectPromptNonSysInplaceEncResumeMode = TRUE; break; case OptionNoIsoCheck: bDontVerifyRescueDisk = TRUE; break; case OptionHistory: { wchar_t szTmp[8] = {0}; bHistory = bHistoryCmdLine = TRUE; if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp))) { if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes")) { bHistory = TRUE; } diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index f725d32b..d5c578df 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -10948,70 +10948,72 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA else userConfig &= ~TC_BOOT_USER_CFG_FLAG_SILENT_MODE; if (!IsDlgButtonChecked (hwndDlg, IDC_ALLOW_ESC_PBA_BYPASS)) userConfig |= TC_BOOT_USER_CFG_FLAG_DISABLE_ESC; else userConfig &= ~TC_BOOT_USER_CFG_FLAG_DISABLE_ESC; } try { BOOL bPasswordCacheEnabled = IsDlgButtonChecked (hwndDlg, IDC_BOOT_LOADER_CACHE_PASSWORD); BOOL bPimCacheEnabled = IsDlgButtonChecked (hwndDlg, IDC_BOOT_LOADER_CACHE_PIM); BootEncObj->WriteBootSectorUserConfig (userConfig, customUserMessage, prop.volumePim, prop.pkcs5); SetDriverConfigurationFlag (TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD, bPasswordCacheEnabled); SetDriverConfigurationFlag (TC_DRIVER_CONFIG_CACHE_BOOT_PIM, (bPasswordCacheEnabled && bPimCacheEnabled)? TRUE : FALSE); SetDriverConfigurationFlag (TC_DRIVER_CONFIG_DISABLE_EVIL_MAID_ATTACK_DETECTION, IsDlgButtonChecked (hwndDlg, IDC_DISABLE_EVIL_MAID_ATTACK_DETECTION)); } catch (Exception &e) { e.Show (hwndDlg); return 1; } EndDialog (hwndDlg, lw); return 1; } case IDC_DISABLE_BOOT_LOADER_PIM_PROMPT: if ((IsDlgButtonChecked (hwndDlg, IDC_DISABLE_BOOT_LOADER_PIM_PROMPT)) && AskWarnYesNo ("DISABLE_BOOT_LOADER_PIM_PROMPT", hwndDlg) == IDNO) { CheckDlgButton (hwndDlg, IDC_DISABLE_BOOT_LOADER_PIM_PROMPT, BST_UNCHECKED); } + break; + case IDC_DISABLE_BOOT_LOADER_OUTPUT: if ((IsDlgButtonChecked (hwndDlg, IDC_DISABLE_BOOT_LOADER_OUTPUT)) && AskWarnYesNo ("CUSTOM_BOOT_LOADER_MESSAGE_PROMPT", hwndDlg) == IDNO) { CheckDlgButton (hwndDlg, IDC_DISABLE_BOOT_LOADER_OUTPUT, BST_UNCHECKED); } break; case IDC_BOOT_LOADER_CACHE_PASSWORD: if (IsDlgButtonChecked (hwndDlg, IDC_BOOT_LOADER_CACHE_PASSWORD)) { Warning ("BOOT_PASSWORD_CACHE_KEYBOARD_WARNING", hwndDlg); EnableWindow (GetDlgItem (hwndDlg, IDC_BOOT_LOADER_CACHE_PIM), TRUE); } else { EnableWindow (GetDlgItem (hwndDlg, IDC_BOOT_LOADER_CACHE_PIM), FALSE); } break; } return 0; } return 0; } void MountSelectedVolume (HWND hwndDlg, BOOL mountWithOptions) { if (!VolumeSelected(hwndDlg)) { Warning ("NO_VOLUME_SELECTED", hwndDlg); } |