diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2014-07-14 17:32:57 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2014-11-08 23:21:21 +0100 |
commit | bbc738c490bcd691151c28f971e0e153777fb255 (patch) | |
tree | 81d6c3dbca12021fc8dd9563462c19836f5591a6 /src/Common/Crypto.c | |
parent | 8bf58486af14c662ed63abea093886bfcf2ddbe5 (diff) | |
download | VeraCrypt-bbc738c490bcd691151c28f971e0e153777fb255.tar.gz VeraCrypt-bbc738c490bcd691151c28f971e0e153777fb255.zip |
Static Code Analysis : Add various NULL pointers checks
Diffstat (limited to 'src/Common/Crypto.c')
-rw-r--r-- | src/Common/Crypto.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c index 3b87572a..dd30e488 100644 --- a/src/Common/Crypto.c +++ b/src/Common/Crypto.c @@ -321,24 +321,28 @@ Cipher *CipherGet (int id) 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)
{
- return CipherGet (cipherId) -> BlockSize;
+ Cipher* pCipher = CipherGet (cipherId);
+ return pCipher? pCipher -> BlockSize : 0;
}
int CipherGetKeySize (int cipherId)
{
- return CipherGet (cipherId) -> KeySize;
+ Cipher* pCipher = CipherGet (cipherId);
+ return pCipher? pCipher -> KeySize : 0;
}
int CipherGetKeyScheduleSize (int cipherId)
{
- return CipherGet (cipherId) -> KeyScheduleSize;
+ Cipher* pCipher = CipherGet (cipherId);
+ return pCipher? pCipher -> KeyScheduleSize : 0;
}
#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)
{
- return HashGet (hashId) -> Deprecated;
+ Hash* pHash = HashGet(hashId);
+ return pHash? pHash -> Deprecated : FALSE;
}
|