Skip to content

"Item with the same key has already been added" extracting tar with duplicate headers #383

@zarenner

Description

@zarenner

SharpZipLib fails to process a tar file that contains duplicate extended headers. Other tar programs (e.g. tar, 7-zip, SharpCompress) appear to handle this fine.

Steps to reproduce

  1. Download https://registry.npmjs.org/jasmine-data-provider/-/jasmine-data-provider-2.2.0.tgz
  2. gunzip (either with sharpziplib or other software)
  3. Attempt to extract, read entries, or list contents of the tar:
using (var fs = File.OpenRead("c:\\jasmine-data-provider-2.2.0.tar"))
using (TarArchive tar = TarArchive.CreateInputTarArchive(fs))
{
    tar.ListContents();
}

Actual behavior

An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)   at ICSharpCode.SharpZipLib.Tar.TarExtendedHeaderReader.Read(Byte[] buffer, Int32 length)   at ICSharpCode.SharpZipLib.Tar.TarInputStream.GetNextEntry()   at ICSharpCode.SharpZipLib.Tar.TarArchive.ListContents()

Version of SharpZipLib

1.2.0

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtarRelated to TAR file format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions