Skip to content

Unable to decompress compressed tar files with ArchiveFactory.OpenArchive #1276

Description

@doxxx

Using SharpCompress 0.47.4, when trying to decompress a gnu tar file compressed using gzip, bzip2 or zstd, I get the following error after the second entry:

dir  size=0 compressed=0 path=./
file size=4149673 compressed=4149673 path=./GHT00710.jpg
SharpCompress.Common.IncompleteArchiveException: Failed to read TAR header
   at SharpCompress.Archives.Tar.TarArchive.LoadEntries(IEnumerable`1 volumes)+MoveNext() in D:\a\sharpcompress\sharpcompress\src\SharpCompress\Archives\Tar\TarArchive.cs:line 179
   at SharpCompress.LazyReadOnlyCollection`1.LazyLoader.MoveNext() in D:\a\sharpcompress\sharpcompress\src\SharpCompress\LazyReadOnlyCollection.cs:line 53

If I use the same test code against an uncompressed tar file, it works fine.

Test code:

using var stream = File.OpenRead(archivePath);
using var archive = ArchiveFactory.OpenArchive(stream);

foreach (var entry in archive.Entries)
{
    var entryType = entry.IsDirectory ? "dir " : "file";
    var key = string.IsNullOrWhiteSpace(entry.Key) ? "<no-name>" : entry.Key;

    Console.WriteLine(
        $"{entryType} size={entry.Size} compressed={entry.CompressedSize} path={key}");
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions