-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Closed
Copy link
Labels
Milestone
Description
Description
TarFile.ExtractToDirectoryInternal() doesn't work with some compressed archives.
The method works in examples from tests of the repo.
But it doesn't work if I try an archive created with 7-Zip or official PowerShell distributive (link is below).
If I try TarReader on the same archives I can read all entries.
Also the method works well if an archive is not compressed.
Small example archives created with 7-Zip
examples.zip
Reproduction Steps
- Download https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.6/powershell-7.3.0-preview.6-linux-x64.tar.gz
- Try read with simple code:
using (var sourceStream = File.OpenRead(args[0]))
using (var decompressorStream = new GZipStream(sourceStream, CompressionMode.Decompress))
{
TarFile.ExtractToDirectory(decompressorStream, args[1], true);
}Expected behavior
The archive is unpacked well.
Actual behavior
Exception throws:
Unhandled exception. System.FormatException: Could not find any recognizable digits. at System.ParseNumbers.StringToInt(ReadOnlySpan`1 s, Int32 radix, Int32 flags, Int32& currPos) at System.Convert.ToInt32(String value, Int32 fromBase) at System.Formats.Tar.TarHelpers.GetTenBaseNumberFromOctalAsciiChars(Span`1 buffer) at System.Formats.Tar.TarHeader.TryReadCommonAttributes(Span`1 buffer) at System.Formats.Tar.TarHeader.TryGetNextHeader(Stream archiveStream, Boolean copyData) at System.Formats.Tar.TarReader.TryGetNextEntryHeader(TarHeader& header, Boolean copyData) at System.Formats.Tar.TarReader.GetNextEntry(Boolean copyData) at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen)
Regression?
No response
Known Workarounds
No response
Configuration
.Net Preview.7
Other information
No response