๐ Bug: System.OverflowException converting the FileStream length to an int
samuel-lucas6 opened this issue ยท 2 comments
Describe the bug
System.OverflowException converting a large FileStream length to an int in GetBufferSize().
To Reproduce
Steps to reproduce the behavior:
- 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):
- OS: Linux
- Version: CLI v2.2.0 Beta
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.
This issue has been fixed in v2.2.1 Beta.