I created simple rar and zip files with WinRar to use for testing Junrar. They contain a simple text file. For the encrypted archives, the password is just "encrypted". See attachments,
For unencrypted.rar, I expected extraction to work. For everything else, I expected RarException. For the zip files, I get unexpected NullPointerException instead. One line of code is sufficient to reproduce the NullPointerException in Junrar.
Archive arc = new Archive(new File("C:/encrypted.zip"));
Root cause is Junrar's Archive.java line 245. The return value of BaseBlock.getHeaderType() is null, and passing a null value to a switch() statement triggers a NullPointerException.
To fix, please add a null check for BaseBlock.getHeaderType() and throw RarException. This simple patch should help improve the graceful error handling of Junrar.
Hello,
I created simple rar and zip files with WinRar to use for testing Junrar. They contain a simple text file. For the encrypted archives, the password is just "encrypted". See attachments,
For unencrypted.rar, I expected extraction to work. For everything else, I expected RarException. For the zip files, I get unexpected NullPointerException instead. One line of code is sufficient to reproduce the NullPointerException in Junrar.
Root cause is Junrar's Archive.java line 245. The return value of BaseBlock.getHeaderType() is null, and passing a null value to a switch() statement triggers a NullPointerException.
241 BaseBlock block = new BaseBlock(baseBlockBuffer); 242 243 block.setPositionInFile(position); 244 245 switch (block.getHeaderType()) {
To fix, please add a null check for BaseBlock.getHeaderType() and throw RarException. This simple patch should help improve the graceful error handling of Junrar.
Thank you, Justin
encrypted.zip unencrypted.zip