mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Static Code Analysis : Add various NULL pointers checks
This commit is contained in:
@@ -321,24 +321,28 @@ Cipher *CipherGet (int id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *CipherGetName (int cipherId)
|
const char *CipherGetName (int cipherId)
|
||||||
{
|
{
|
||||||
return CipherGet (cipherId) -> Name;
|
Cipher* pCipher = CipherGet (cipherId);
|
||||||
|
return pCipher? pCipher -> Name : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int CipherGetBlockSize (int cipherId)
|
int CipherGetBlockSize (int cipherId)
|
||||||
{
|
{
|
||||||
return CipherGet (cipherId) -> BlockSize;
|
Cipher* pCipher = CipherGet (cipherId);
|
||||||
|
return pCipher? pCipher -> BlockSize : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CipherGetKeySize (int cipherId)
|
int CipherGetKeySize (int cipherId)
|
||||||
{
|
{
|
||||||
return CipherGet (cipherId) -> KeySize;
|
Cipher* pCipher = CipherGet (cipherId);
|
||||||
|
return pCipher? pCipher -> KeySize : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CipherGetKeyScheduleSize (int cipherId)
|
int CipherGetKeyScheduleSize (int cipherId)
|
||||||
{
|
{
|
||||||
return CipherGet (cipherId) -> KeyScheduleSize;
|
Cipher* pCipher = CipherGet (cipherId);
|
||||||
|
return pCipher? pCipher -> KeyScheduleSize : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TC_WINDOWS_BOOT
|
#ifndef TC_WINDOWS_BOOT
|
||||||
@@ -715,15 +719,17 @@ int HashGetIdByName (char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *HashGetName (int hashId)
|
const char *HashGetName (int hashId)
|
||||||
{
|
{
|
||||||
return HashGet (hashId) -> Name;
|
Hash* pHash = HashGet(hashId);
|
||||||
|
return pHash? pHash -> Name : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL HashIsDeprecated (int hashId)
|
BOOL HashIsDeprecated (int hashId)
|
||||||
{
|
{
|
||||||
return HashGet (hashId) -> Deprecated;
|
Hash* pHash = HashGet(hashId);
|
||||||
|
return pHash? pHash -> Deprecated : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ int CipherGetBlockSize (int cipher);
|
|||||||
int CipherGetKeySize (int cipher);
|
int CipherGetKeySize (int cipher);
|
||||||
int CipherGetKeyScheduleSize (int cipher);
|
int CipherGetKeyScheduleSize (int cipher);
|
||||||
BOOL CipherSupportsIntraDataUnitParallelization (int cipher);
|
BOOL CipherSupportsIntraDataUnitParallelization (int cipher);
|
||||||
char * CipherGetName (int cipher);
|
const char * CipherGetName (int cipher);
|
||||||
|
|
||||||
int CipherInit (int cipher, unsigned char *key, unsigned char *ks);
|
int CipherInit (int cipher, unsigned char *key, unsigned char *ks);
|
||||||
int EAInit (int ea, unsigned char *key, unsigned char *ks);
|
int EAInit (int ea, unsigned char *key, unsigned char *ks);
|
||||||
@@ -302,7 +302,7 @@ int EAGetPreviousCipher (int ea, int previousCipherId);
|
|||||||
int EAIsFormatEnabled (int ea);
|
int EAIsFormatEnabled (int ea);
|
||||||
BOOL EAIsModeSupported (int ea, int testedMode);
|
BOOL EAIsModeSupported (int ea, int testedMode);
|
||||||
|
|
||||||
char *HashGetName (int hash_algo_id);
|
const char *HashGetName (int hash_algo_id);
|
||||||
BOOL HashIsDeprecated (int hashId);
|
BOOL HashIsDeprecated (int hashId);
|
||||||
|
|
||||||
int GetMaxPkcs5OutSize (void);
|
int GetMaxPkcs5OutSize (void);
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw)
|
|||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
if (hPassword == NULL)
|
if (hPassword == NULL)
|
||||||
|
{
|
||||||
|
if (ptrPw)
|
||||||
{
|
{
|
||||||
unsigned char *pw;
|
unsigned char *pw;
|
||||||
len = ptrPw->Length;
|
len = ptrPw->Length;
|
||||||
@@ -76,6 +78,9 @@ BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wchar_t s[MAX_PASSWORD + 1];
|
wchar_t s[MAX_PASSWORD + 1];
|
||||||
@@ -114,7 +119,7 @@ BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChangePwd (char *lpszVolume, Password *oldPassword, Password *newPassword, int pkcs5, HWND hwndDlg)
|
int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassword, int pkcs5, HWND hwndDlg)
|
||||||
{
|
{
|
||||||
int nDosLinkCreated = 1, nStatus = ERR_OS_ERROR;
|
int nDosLinkCreated = 1, nStatus = ERR_OS_ERROR;
|
||||||
char szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
|
char szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
|
||||||
@@ -138,9 +143,16 @@ int ChangePwd (char *lpszVolume, Password *oldPassword, Password *newPassword, i
|
|||||||
|
|
||||||
if (oldPassword->Length == 0 || newPassword->Length == 0) return -1;
|
if (oldPassword->Length == 0 || newPassword->Length == 0) return -1;
|
||||||
|
|
||||||
|
if (!lpszVolume)
|
||||||
|
{
|
||||||
|
nStatus = ERR_OUTOFMEMORY;
|
||||||
|
handleError (hwndDlg, nStatus);
|
||||||
|
return nStatus;
|
||||||
|
}
|
||||||
|
|
||||||
WaitCursor ();
|
WaitCursor ();
|
||||||
|
|
||||||
CreateFullVolumePath (szDiskFile, lpszVolume, &bDevice);
|
CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), lpszVolume, &bDevice);
|
||||||
|
|
||||||
if (bDevice == FALSE)
|
if (bDevice == FALSE)
|
||||||
{
|
{
|
||||||
@@ -148,7 +160,7 @@ int ChangePwd (char *lpszVolume, Password *oldPassword, Password *newPassword, i
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nDosLinkCreated = FakeDosNameForDevice (szDiskFile, szDosDevice, szCFDevice, FALSE);
|
nDosLinkCreated = FakeDosNameForDevice (szDiskFile, szDosDevice, sizeof(szDosDevice), szCFDevice, sizeof(szCFDevice),FALSE);
|
||||||
|
|
||||||
if (nDosLinkCreated != 0)
|
if (nDosLinkCreated != 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ typedef struct
|
|||||||
void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled );
|
void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled );
|
||||||
BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem);
|
BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem);
|
||||||
BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw);
|
BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw);
|
||||||
int ChangePwd (char *lpszVolume, Password *oldPassword, Password *newPassword, int pkcs5, HWND hwndDlg);
|
int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassword, int pkcs5, HWND hwndDlg);
|
||||||
|
|
||||||
#endif // defined(_WIN32) && !defined(TC_WINDOWS_DRIVER)
|
#endif // defined(_WIN32) && !defined(TC_WINDOWS_DRIVER)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user