-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TarFile.ExtractToDirectory() doesn't work sometimes with compressed archives #74242
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsDescriptionTarFile.ExtractToDirectoryInternal() doesn't work with some compressed archives. The method works in examples from tests of the repo. 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 Reproduction Steps
using (var sourceStream = File.OpenRead(args[0]))
using (var decompressorStream = new GZipStream(sourceStream, CompressionMode.Decompress))
{
TarFile.ExtractToDirectory(decompressorStream, args[1], true);
} Expected behaviorThe archive is unpacked well. Actual behaviorException throws:
Regression?No response Known WorkaroundsNo response Configuration.Net Preview.7 Other informationNo response
|
I tried your scenario with 7.0.0-rc1 and didn't get the exception but I did notice that the only file extracted was ThirdPartyNotices.txt. |
I have seen this with several archives - after successfully reading the first entry, the subsequent TarReader.GetNextEntry() returns null (for compressed file). |
@carlossanlop I'm still able to repro using the latest bits. |
Had a call with @jozkee . We found the root cause of this bug: When reading unseekable streams (like a GZipStream), and encounter a regular file entry (ThirdPartyNotices.txt) with lots of data, TarFile writes it successfully to disk, but attempting to visit the next entry fails because we not advancing the stream correctly: We should always skip the padding after the data, but the current condition is only advancing the padding if the user did not advance the whole data stream. |
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
Expected behavior
The archive is unpacked well.
Actual behavior
Exception throws:
Regression?
No response
Known Workarounds
No response
Configuration
.Net Preview.7
Other information
No response
The text was updated successfully, but these errors were encountered: