samuel-lucas6 / Kryptor

A simple, modern, and secure encryption and signing tool that aims to be a better version of age and Minisign.
https://www.kryptor.co.uk
GNU General Public License v3.0
431 stars 33 forks source link

🐛 Bug: System.OverflowException converting the FileStream length to an int #9

Closed samuel-lucas6 closed 3 years ago

samuel-lucas6 commented 3 years ago

Describe the bug System.OverflowException converting a large FileStream length to an int in GetBufferSize().

To Reproduce Steps to reproduce the behavior:

  1. Try to encrypt a 3 GB file.

Expected behaviour File encryption should occur as expected without an exception.

Error log Unhandled exception. System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ThrowInt32OverflowException() at System.Convert.ToInt32(Int64 value) at KryptorCLI.FileHandling.GetBufferSize(Int64 fileStreamLength) at KryptorCLI.Encryption.EncryptFile(String filePath, String encryptedFilePath, Byte[] salt, Byte[] nonce, ValueTuple`2 keys) at KryptorCLI.Encryption.InitializeEncryption(String filePath, Byte[] passwordBytes) at KryptorCLI.FileEncryption.CallEncryption(Boolean encryption, String filePath, Byte[] passwordBytes) at KryptorCLI.FileEncryption.GetFilePaths(Boolean encryption, String[] filePaths, Byte[] passwordBytes) at KryptorCLI.FileEncryption.StartEncryption(Boolean encryption, String[] filePaths, Byte[] passwordBytes, String keyfilePath) at KryptorCLI.CommandLine.CallEncryption(Boolean encryption, Char[] password, String keyfilePath, String[] filePaths) at KryptorCLI.CommandLine.ValidateFileEncryptionInput(Boolean encryption, Char[] password, String keyfilePath, String[] filePaths) at KryptorCLI.Program.OnExecute() --- End of stack trace from previous location where exception was thrown --- at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.Invoke(MethodInfo method, Object instance, Object[] arguments) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](CommandLineContext context) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](IConsole console, String[] args) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](String[] args) at KryptorCLI.Program.Main(String[] args) Aborted (core dumped)

Desktop (please complete the following information):

samuel-lucas6 commented 3 years ago

Should be fixed now, but I'm going to do some more testing. This is only an issue in the CLI version luckily. It will be fixed for v2.3.0 Beta, which is going to be released relatively soon.

Edit: Going to fix this for v2.2.1 Beta since there are lots of code improvements that I'm working on for v2.3.0 Beta. I've added the new features for v2.3.0, but it's going to take a while to go through the code and clean it up.

samuel-lucas6 commented 3 years ago

This issue has been fixed in v2.2.1 Beta.