Skip to content

[BUG]com.github.junrar.exception.CorruptHeaderException when parsing stream headers on v2 archive #216

@D1manCh

Description

@D1manCh

Describe the bug
When opening an old rar v2 file as a stream, an exception occurs when parsing headers, since the file does not have an EndArcHeader and the stream length is defined as Long.MAX_VALUE.

To Reproduce

  try (InputStream is = getClass().getResourceAsStream("audio/BoatModernEnglish-audio-text-unpack20.rar")) {
                try (Archive archive = new Archive(is)) {
...

Expected behavior
No Exception

File
src/test/resources/com/github/junrar/audio/BoatModernEnglish-audio-text-unpack20.rar

Environment (please complete the following information):

  • OS: [Linux]
  • Junrar version: [7.5.5]

Additional context
May be change InputStreamVolume/getLength to

public long getLength() {
        try {
            return inputStream.available();
        } catch (IOException e) {
            return Long.MAX_VALUE;
        }
    }

?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions