TarInputStream.GetNextEntry hangs on corrupt archive
See original GitHub issueSteps to reproduce
var httpClient = new HttpClient();
var stream = await httpClient.GetStreamAsync("https://files.pythonhosted.org/packages/04/b5/fea02ac9306b5d56a5019133f4edda6c9e3cfbd1b5ce663158486ba77eea/diffpy.srfit-1.3.tar.gz");
var gzipStream = new GZipInputStream(stream);
var tarStream = new TarInputStream(gzipStream, Encoding.ASCII);
while (tarStream.CanRead)
{
var entry = tarStream.GetNextEntry();
if (entry == null)
{
break;
}
}
tarStream.Close();
gzipStream.Close();
Expected behavior
Exception should be thrown if archive cannot be processed.
Actual behavior
GetNextEntry() call hangs.
Version of SharpZipLib
1.3.3
Obtained from (only keep the relevant lines)
- Package installed using NuGet
Other notes
Archive is an older python package hosted on PyPi.
Inspecting archive with 7zip shows “Unexpected end of data” for many files.
Also tried fully reading http response stream into byte array and reading from memory stream, same problem.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
ExtractContent() of a corrupt file holds the extracting file open
After ExtractContents() crashes open Windows File Explorer and try to delete THE PARTIALLY UNZIPPED CONTENTS. Do this on a WINDOWS box, not ......
Read more >ZipInputStream.GetNextEntry hangs permanently #300
ZipInputStream.GetNextEntry hangs permanently when attempting to extract the attached archive. I'm using the latest SharpZipLib NuGet ...
Read more >Index (Apache Commons Compress 1.21 API)
Creates a new zip entry taking some information from the given file and using the provided name. createArchiveInputStream(String, InputStream) - Method in class...
Read more >ZipInputStream getNextEntry is null when extracting .zip files
Therefore, reading a zip file in a sequence, by using a stream, sometimes results in a "guess", which can fail. This is a...
Read more >Index (Apache Commons Compress 1.23.0 API)
Implements the "ar" archive format as an input stream. ArArchiveInputStream(InputStream) - Constructor for class org.apache.commons.compress.archivers.ar.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mikaeleiman Yeah, then it probably is #788. It’s fixed in
master
and should be released with 1.4.1 pretty soon. The example file you provided extracts usingmaster
as well:Example file:
example-762.tar.gz
I looked into our code, and it seems that SharpZipLib 1.3.3 handles the file, but 1.4.0 does not. Not sure why we bumped to 1.4.0, but I suspect it was for the dotnet6 support. Seems like 1.3.3 is working fine for our purposes, though.