Try to read links-strip.tar from https://github.com/npm/node-tar/tree/f12992932f171ea248b27fad95e7d489a56d31ed/test/fixtures/tars:
Unhandled exception. System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.Stream.ReadAtLeastCore(Span`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream)
at System.IO.Stream.ReadExactly(Span`1 buffer)
at System.Formats.Tar.TarHeader.TryGetNextHeader(Stream archiveStream, Boolean copyData, TarEntryFormat initialFormat)
at System.Formats.Tar.TarReader.TryGetNextEntryHeader(Boolean copyData)
at System.Formats.Tar.TarReader.GetNextEntry(Boolean copyData)
at Program.<<Main>$>g__ReadTar|0_0(String path, Boolean useGz) in /home/am11/projects/consoletar/Program.cs:line 26
at Program.<Main>$(String[] args) in /home/am11/projects/consoletar/Program.cs:line 15
Repro:
# bash on linux-x64# daily build
$ dotnet7 --version
7.0.100-rc.2.22419.21
$ dotnet7 new console -n consoletar;cd$_
$ cat > Program.cs <<EOFusing System;using System.Formats.Tar;using System.IO;using System.IO.Compression;foreach (string file in Directory.EnumerateFiles(Environment.CurrentDirectory, "*.tgz", SearchOption.AllDirectories)){ Console.WriteLine("{0} ->", file); ReadTar(file, true);}foreach (string file in Directory.EnumerateFiles(Environment.CurrentDirectory, "*.tar", SearchOption.AllDirectories)){ Console.WriteLine("{0} ->", file); ReadTar(file);}Console.WriteLine("Done");void ReadTar(string path, bool useGz = false){ using FileStream sourceStream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); using var reader = new TarReader(useGz ? new GZipStream(sourceStream, CompressionMode.Decompress) : sourceStream); TarEntry? entry = null; while ((entry = reader.GetNextEntry()) is not null) { Console.WriteLine("\t{0} ({1} bytes)", entry.Name, entry.Length); }}EOF
$ git clone https://github.com/npm/node-tar
$ dotnet7 run
...
Unhandled exception. System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
...
# test with GNU tar(1)
$ mkdir temp
$ tar xzf node-tar/test/fixtures/tars/links-strip.tar -C temp
# succeeds
Try to read
links-strip.tarfrom https://github.com/npm/node-tar/tree/f12992932f171ea248b27fad95e7d489a56d31ed/test/fixtures/tars:Repro: