Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException with RarReader since 0.33 #783

Open
IS4Code opened this issue Dec 1, 2023 · 2 comments
Open

NullReferenceException with RarReader since 0.33 #783

IS4Code opened this issue Dec 1, 2023 · 2 comments

Comments

@IS4Code
Copy link

IS4Code commented Dec 1, 2023

An error seems to have been introduced in 0.33 that affects reading some RAR archives using the RarReader.
Example RAR with the issue: https://telparia.com/fileFormatSamples/archive/rar/comment.rar
Even iterating through the archive throws an exception:

using var inputFile = File.Open("comment.rar", FileMode.Open);
var reader = RarReader.Open(inputFile);

while(reader.MoveToNextEntry()) ;

Exception:

   at SharpCompress.Common.Rar.RarVolume.<GetVolumeFileParts>d__11.MoveNext()
   at SharpCompress.Readers.Rar.RarReader.<GetEntries>d__13.MoveNext()
   at SharpCompress.Readers.AbstractReader`2.LoadStreamForReading(Stream stream)
   at SharpCompress.Readers.AbstractReader`2.MoveToNextEntry()

This works fine on 0.32.2, but does not work on 0.33 to 0.34.2.

adamhathcock added a commit that referenced this issue Dec 11, 2023
Dont crash on reading rar5 comment #783
@IS4Code
Copy link
Author

IS4Code commented Jan 3, 2024

0.35 fixed this issue, but there is another null-related one with https://telparia.com/fileFormatSamples/archive/rar/password.rar on IReader.MoveToNextEntry:

System.ArgumentNullException: String reference not set to an instance of a String. (Parameter 's')

  Stack Trace: 
    Encoding.GetBytes(String s)
    UTF8EncodingSealed.GetBytes(String s)
    CryptKey5.GenerateRarPBKDF2Key(String password, Byte[] salt, Int32 iterations, Int32 keyLength)
    CryptKey5.Transformer(Byte[] salt)
    RarCryptoWrapper.ctor(Stream actualStream, Byte[] salt, ICryptKey key)
    RarHeaderFactory.TryReadNextHeader(Stream stream)
    RarHeaderFactory.ReadHeaders(Stream stream)+MoveNext()
    RarVolume.GetVolumeFileParts()+MoveNext()
    RarReader.GetEntries(Stream stream)+MoveNext()
    AbstractReader`2.LoadStreamForReading(Stream stream)

@adamhathcock
Copy link
Owner

Looks like #798 will address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants