VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2022-03-26 18:46:01 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2022-03-26 21:14:57 +0100
commit05fd14006d0ee5991f207d2f98a1a9ab0b4060fb (patch)
treea64bce23d59db0ffc2128e38303f79e2e3f76aa9
parent533269ca9a13736eb96196b41b38e7c9b04577ae (diff)
downloadVeraCrypt-05fd14006d0ee5991f207d2f98a1a9ab0b4060fb.tar.gz
VeraCrypt-05fd14006d0ee5991f207d2f98a1a9ab0b4060fb.zip
Remove dead code from chacha_ECRYPT_encrypt_bytes (Coverity)
-rw-r--r--src/Crypto/chacha-xmm.c23
-rw-r--r--src/Setup/SelfExtract.c8
2 files changed, 16 insertions, 15 deletions
diff --git a/src/Crypto/chacha-xmm.c b/src/Crypto/chacha-xmm.c
index 198d0b5b..478de594 100644
--- a/src/Crypto/chacha-xmm.c
+++ b/src/Crypto/chacha-xmm.c
@@ -139,22 +139,15 @@ void chacha_ECRYPT_encrypt_bytes(size_t bytes, uint32* x, const uint8* m, uint8*
#endif
if (!bytes) return;
- for (;;) {
- salsa20_wordtobyte(output,x, r);
- x[12] = PLUSONE(x[12]);
- if (!x[12]) {
- x[13] = PLUSONE(x[13]);
- /* stopping at 2^70 bytes per nonce is user's responsibility */
- }
- if (bytes <= 64) {
- for (i = 0;i < bytes;++i) out[i] = m[i] ^ output[i];
- return;
- }
- for (i = 0;i < 64;++i) out[i] = m[i] ^ output[i];
- bytes -= 64;
- out += 64;
- m += 64;
+ // bytes is now guaranteed to be between 1 and 63
+ salsa20_wordtobyte(output,x, r);
+ x[12] = PLUSONE(x[12]);
+ if (!x[12]) {
+ x[13] = PLUSONE(x[13]);
+ /* stopping at 2^70 bytes per nonce is user's responsibility */
}
+
+ for (i = 0;i < bytes;++i) out[i] = m[i] ^ output[i];
}
#endif
diff --git a/src/Setup/SelfExtract.c b/src/Setup/SelfExtract.c
index d5dd3d2c..c672c364 100644
--- a/src/Setup/SelfExtract.c
+++ b/src/Setup/SelfExtract.c
@@ -595,6 +595,14 @@ BOOL SelfExtractInMemory (wchar_t *path, BOOL bSkipCountCheck)
if (compressedLen != fileDataEndPos - fileDataStartPos - 8 + 1)
{
Error ("DIST_PACKAGE_CORRUPTED", NULL);
+ return FALSE;
+ }
+
+ // Test to make Coverity happy. It will always be false
+ if (uncompressedLen >= (INT_MAX - 524288))
+ {
+ Error ("DIST_PACKAGE_CORRUPTED", NULL);
+ return FALSE;
}
decompressedDataLen = uncompressedLen;