NotSupportedException when decompress a GZIP file #435

Closed
opened 2026-01-29 22:12:01 +00:00 by claunia · 5 comments
Owner

Originally created by @waldo2188 on GitHub (Jan 13, 2021).

Hi !
We encountered an error with version 0.27 when we tried to decompress a GZIP file. The method MoveToNextEntry() throw a NotSupportedException exception when the code tried to access to the Length property of class SharpCompress.IO.RewindableStream.

You can reproduce this behaviour with the code bellow and the file attached: simple.gz.

FileStream fStream = new FileStream("file/simple.gz", FileMode.Open);
using (SharpCompress.Readers.IReader reader = SharpCompress.Readers.ReaderFactory.Open(fStream))
{
	while (reader.MoveToNextEntry()) // Crash here
	{ }
}
Originally created by @waldo2188 on GitHub (Jan 13, 2021). Hi ! We encountered an error with version 0.27 when we tried to decompress a GZIP file. The method `MoveToNextEntry()` throw a `NotSupportedException` exception when the code tried to access to the `Length` property of class `SharpCompress.IO.RewindableStream`. You can reproduce this behaviour with the code bellow and the file attached: [simple.gz](https://github.com/adamhathcock/sharpcompress/files/5808002/simple.gz). ``` FileStream fStream = new FileStream("file/simple.gz", FileMode.Open); using (SharpCompress.Readers.IReader reader = SharpCompress.Readers.ReaderFactory.Open(fStream)) { while (reader.MoveToNextEntry()) // Crash here { } } ```
Author
Owner

@adamhathcock commented on GitHub (Jan 13, 2021):

Could you put the full stack trace you're seeing?

I realized I didn't have any tests covering what you did and I did change code in that area but I can't reproduce your problem.

@adamhathcock commented on GitHub (Jan 13, 2021): Could you put the full stack trace you're seeing? I realized I didn't have any tests covering what you did and I did change code in that area but I can't reproduce your problem.
Author
Owner

@waldo2188 commented on GitHub (Jan 13, 2021):

The stack trace as you ask :

System.NotSupportedException
  HResult=0x80131515
  Message=Specified method is not supported.
  Source=SharpCompress
  StackTrace :
   at SharpCompress.IO.RewindableStream.get_Length() in C:\Projets\sharpcompress\src\SharpCompress\IO\RewindableStream.cs:line 87
   at SharpCompress.Common.GZip.GZipFilePart..ctor(Stream stream, ArchiveEncoding archiveEncoding) in C:\Projets\sharpcompress\src\SharpCompress\Common\GZip\GZipFilePart.cs:line 24
   at SharpCompress.Common.GZip.GZipEntry.<GetEntries>d__30.MoveNext() in C:\Projets\sharpcompress\src\SharpCompress\Common\GZip\GZipEntry.cs:line 46
   at SharpCompress.Readers.AbstractReader`2.LoadStreamForReading(Stream stream) in C:\Projets\sharpcompress\src\SharpCompress\Readers\AbstractReader.cs:line 107
   at SharpCompress.Readers.AbstractReader`2.MoveToNextEntry() in C:\Projets\sharpcompress\src\SharpCompress\Readers\AbstractReader.cs:line 82
   at GST.FileGrabber.Test.ZipTest.MustUnGZipFile() in C:\Projets\test\ZipTest.cs:line 18
@waldo2188 commented on GitHub (Jan 13, 2021): The stack trace as you ask : ``` System.NotSupportedException HResult=0x80131515 Message=Specified method is not supported. Source=SharpCompress StackTrace : at SharpCompress.IO.RewindableStream.get_Length() in C:\Projets\sharpcompress\src\SharpCompress\IO\RewindableStream.cs:line 87 at SharpCompress.Common.GZip.GZipFilePart..ctor(Stream stream, ArchiveEncoding archiveEncoding) in C:\Projets\sharpcompress\src\SharpCompress\Common\GZip\GZipFilePart.cs:line 24 at SharpCompress.Common.GZip.GZipEntry.<GetEntries>d__30.MoveNext() in C:\Projets\sharpcompress\src\SharpCompress\Common\GZip\GZipEntry.cs:line 46 at SharpCompress.Readers.AbstractReader`2.LoadStreamForReading(Stream stream) in C:\Projets\sharpcompress\src\SharpCompress\Readers\AbstractReader.cs:line 107 at SharpCompress.Readers.AbstractReader`2.MoveToNextEntry() in C:\Projets\sharpcompress\src\SharpCompress\Readers\AbstractReader.cs:line 82 at GST.FileGrabber.Test.ZipTest.MustUnGZipFile() in C:\Projets\test\ZipTest.cs:line 18 ```
Author
Owner

@adamhathcock commented on GitHub (Jan 13, 2021):

Thanks that narrowed it down. Will release a fix.

@adamhathcock commented on GitHub (Jan 13, 2021): Thanks that narrowed it down. Will release a fix.
Author
Owner

@adamhathcock commented on GitHub (Jan 13, 2021):

0.27.1 has been released

@adamhathcock commented on GitHub (Jan 13, 2021): 0.27.1 has been released
Author
Owner

@waldo2188 commented on GitHub (Jan 13, 2021):

Thank you very much for the fast correction!!

@waldo2188 commented on GitHub (Jan 13, 2021): Thank you very much for the fast correction!!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#435