TurboPack / LockBox

LockBox is a Delphi and C++Builder library for cryptography.
106 stars 38 forks source link

Memory Corruption Error When Doing Base64 Decryption #6

Closed srmitch closed 8 years ago

srmitch commented 8 years ago

TurboPack LockBox3 v3.5.0 (Delphi 10 Seattle GetIt package).

The following error is raised by FastMM4 in full debug mode when doing a Base64 decryption: 'FastMM has detected an error during a ReallocMem operation. The block footer has been corrupted...'

The bug appears to be an 'off-by-one' indexing problem in the TBase64Conv.Decrypt method. The local variable 'base64_Fragment' was changed from an ANSIString to a TBytes type at some stage and the in-buffer read pointer index was not adjusted. Line 250 in 'uTPLb_Base64.pas' should be:

FInBuffer.Read( base64_Fragment[0], FromBase64_BufferSize);

FYI, I have attached the full memory manager event log. MemoryManager_EventLog.txt

HTH. Steve

srmitch commented 8 years ago

Meant for LockBox3, has been opened there.