diff --git a/src/core/Cryptography.cpp b/src/core/Cryptography.cpp index 925133d2b..7d9352d9a 100644 --- a/src/core/Cryptography.cpp +++ b/src/core/Cryptography.cpp @@ -331,8 +331,11 @@ static void encr_data(uint8_t data[], uint32_t d_len, fcrypt_ctx cx[1]) uint32_t j = 0; /* increment encryption nonce */ while (j < 8) - if (!++cx->nonce[j]) - ++j; + { + if (++cx->nonce[j]) + break; + ++j; + } /* encrypt the nonce to form next xor buffer */ aes_encrypt_block(cx->nonce, cx->encr_bfr, cx->encr_ctx); pos = 0; diff --git a/src/core/FtpFileSystem.cpp b/src/core/FtpFileSystem.cpp index 2e162d5f5..4f6aebcb6 100644 --- a/src/core/FtpFileSystem.cpp +++ b/src/core/FtpFileSystem.cpp @@ -2179,7 +2179,7 @@ void TFTPFileSystem::ReadCurrentDirectory() if (Result) { - if (Path.IsEmpty() || !base::UnixIsAbsolutePath(Path)) + if (!Path.IsEmpty() && !base::UnixIsAbsolutePath(Path)) { Path = UnicodeString(ROOTDIRECTORY) + Path; } @@ -4221,9 +4221,12 @@ static bool VerifyNameMask(const UnicodeString & AName, const UnicodeString & AM bool Result = true; UnicodeString Name = AName; UnicodeString Mask = AMask; - int32_t Pos = Mask.Pos(L"*"); - while (Result && (Pos > 0)) + int32_t Pos = 0; + while (Result) { + Pos = Mask.Pos(L"*"); + if (Pos <= 0) + break; // Pos will typically be 1 here, so not actual comparison is done Result = ::SameText(Mask.SubString(1, Pos - 1), Name.SubString(1, Pos - 1)); if (Result) diff --git a/src/windows/Setup.cpp b/src/windows/Setup.cpp index 9f1857663..e702d0499 100644 --- a/src/windows/Setup.cpp +++ b/src/windows/Setup.cpp @@ -1678,9 +1678,12 @@ static void InsertDonateLink(void * /*Data*/, TObject * Sender) UnicodeString StoreLink = FORMAT(L"%s", (StoreUrl, StoreButton)); UnicodeString PlainBody = HTMLDecode(DocumentBody); - int P1 = PlainBody.Pos(L"<"); int P2 = PlainBody.Pos(L">"); - while ((P1 > 0) && (P2 > 0) && (P1 < P2)) + while (true) { + int P1 = PlainBody.Pos(L"<"); + int P2 = PlainBody.Pos(L">"); + if (P1 <= 0 || P2 <= 0 || P1 >= P2) + break; PlainBody.Delete(P1, P2 - P1 + 1); } while ((P1 = PlainBody.Pos(L" ")) > 0)