Skip to content

Commit

Permalink
Fix several refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
ssvine committed Dec 20, 2024
1 parent 639a85d commit b7220d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/core/Cryptography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions src/core/FtpFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions src/windows/Setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1678,9 +1678,12 @@ static void InsertDonateLink(void * /*Data*/, TObject * Sender)
UnicodeString StoreLink = FORMAT(L"<a href=\"%s\">%s</a>", (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)
Expand Down

0 comments on commit b7220d6

Please sign in to comment.