Closed samuel-lucas6 closed 2 years ago
After some investigation last night, a mistake with mod (%) usage means Kryptor v3 sometimes removes the last 16,384 byte chunk from decrypted files when the file shouldn't be truncated at all.
Here are the guilty lines of code:
https://github.com/samuel-lucas6/Kryptor/blob/v3.1.0/src/KryptorCLI/FileEncryption/EncryptFile.cs#L68 https://github.com/samuel-lucas6/Kryptor/blob/v3.1.0/src/KryptorCLI/FileEncryption/DecryptFile.cs#L88
It's frustrating and upsetting that I missed this. Rather stupidly, none of my testing used files with a length that would catch this problem. I'm extremely sorry for any damage this has caused. I intend to do a hotfix release later today. As the current code contains breaking changes for v4, I will likely reverse the changes for this release and then add them back again after the release has been published.
Description
I received an email yesterday afternoon reporting an issue where files of a certain length get decrypted to an incorrect size.
Steps to reproduce
dd if=/dev/zero of=data bs=1M count=1 iflag=fullblock
.kryptor -e -p:test data.bin
.kryptor -d -p:test data.bin.kryptor
.Expected behaviour
The decrypted file should be the same size as the original file and have the same SHA256 hash.
Platform info