Unpopulated ArchiveEntry.Key from unix tar.gz #93

Closed
opened 2026-01-29 22:06:28 +00:00 by claunia · 7 comments
Owner

Originally created by @FelixTurtur on GitHub (Mar 3, 2016).

Hi,

We've come across an issue when trying to extract tar.gz archives created in ubuntu because the initial archive entry has an empty Key property (in fact most fields, Crc, ArchivedTime, Size, filePart.FilePartName.. are empty) and we get a null reference exception when trying to extract it.
I was looking at issue #128 which seemed similar, but these not being git archives, the fix doesn't solve this issue. I have noted that extracting and recreating the gz archive in windows via 7z results in an tar.gz archive which can then be opened by SharpCompress, so I assume the issue relates to them specifically being unix-created archives.

I've attached one which I've created and am unable to open. I've tried debugging to see if anything obvious jumps out, but I'm afraid I don't really know much about the intricacies of archive files to understand what's amiss.
archive.tar.gz

State of the GZipArchiveEntry:
unpopulatedarchiveentry

Originally created by @FelixTurtur on GitHub (Mar 3, 2016). Hi, We've come across an issue when trying to extract tar.gz archives created in ubuntu because the initial archive entry has an empty Key property (in fact most fields, Crc, ArchivedTime, Size, filePart.FilePartName.. are empty) and we get a null reference exception when trying to extract it. I was looking at issue #128 which seemed similar, but these not being git archives, the fix doesn't solve this issue. I have noted that extracting and recreating the gz archive in windows via 7z results in an tar.gz archive which can then be opened by SharpCompress, so I assume the issue relates to them specifically being unix-created archives. I've attached one which I've created and am unable to open. I've tried debugging to see if anything obvious jumps out, but I'm afraid I don't really know much about the intricacies of archive files to understand what's amiss. [archive.tar.gz](https://github.com/adamhathcock/sharpcompress/files/156789/archive.tar.gz) State of the GZipArchiveEntry: ![unpopulatedarchiveentry](https://cloud.githubusercontent.com/assets/3588810/13495256/8f0bcf7c-e141-11e5-8ad6-cfcdaf9f1f26.JPG)
Author
Owner

@adamhathcock commented on GitHub (Mar 30, 2016):

I just ran your archive with the latest code and it seemed fine. I haven't published a new version with the issue you referred to so maybe that's your problem?

@adamhathcock commented on GitHub (Mar 30, 2016): I just ran your archive with the latest code and it seemed fine. I haven't published a new version with the issue you referred to so maybe that's your problem?
Author
Owner

@FelixTurtur commented on GitHub (Mar 30, 2016):

I can't open it using 11.5 and built latest code at the time of writing the issue (to check the issue-fix I mentioned), which also didn't help. Just opening it using ArchiveFactory.Open(filePath) results in a single entry with null Key, as above. Are tar.gz archives supposed to be opened another way?

@FelixTurtur commented on GitHub (Mar 30, 2016): I can't open it using 11.5 and built latest code at the time of writing the issue (to check the issue-fix I mentioned), which also didn't help. Just opening it using `ArchiveFactory.Open(filePath)` results in a single entry with null Key, as above. Are tar.gz archives supposed to be opened another way?
Author
Owner

@adamhathcock commented on GitHub (Mar 30, 2016):

I tested with ReaderFactory I'll try your way

@adamhathcock commented on GitHub (Mar 30, 2016): I tested with `ReaderFactory` I'll try your way
Author
Owner

@adamhathcock commented on GitHub (Mar 30, 2016):

Oh wait. I see the issue. ArchiveFactory doesn't support doing tar.gz because it's random access.

If you want to read entries out of a tar.gz without ungzipping the tar first then you need to use ReaderFactory

@adamhathcock commented on GitHub (Mar 30, 2016): Oh wait. I see the issue. `ArchiveFactory` doesn't support doing tar.gz because it's random access. If you want to read entries out of a tar.gz without ungzipping the tar first then you need to use `ReaderFactory`
Author
Owner

@adamhathcock commented on GitHub (Mar 30, 2016):

A GZipArchive will only ever have one entry and having a filename is optional. GZip has a few headers but it's mostly lipstick on the deflate algorithm to be a single compressed file. Tars have actual entries. This is why this behavior is weird.

@adamhathcock commented on GitHub (Mar 30, 2016): A GZipArchive will only ever have one entry and having a filename is optional. GZip has a few headers but it's mostly lipstick on the deflate algorithm to be a single compressed file. Tars have actual entries. This is why this behavior is weird.
Author
Owner

@FelixTurtur commented on GitHub (Mar 31, 2016):

Thanks, I'm using ReaderFactory now without any issue.

@FelixTurtur commented on GitHub (Mar 31, 2016): Thanks, I'm using `ReaderFactory` now without any issue.
Author
Owner

@lsantos124 commented on GitHub (Feb 21, 2018):

I am using ReaderFactory to try to decompress a Unix-created .gz archive and it does not seem to work. It seems to be the same issue as Felix's issue. I noticed that when I uncompressed it through 7zip and then rezipped it into a .gz file on Windows, that it was able to be unzipped. I have attached the windows created .gz and the unix created .gz.

windows_created.bson.gz
unix_created.bson.gz

I am using the following code:

fail

The unix_created .gz file fails at the archive.WriteToDirectory( .. ) line. Below shows that the unix_created archive shows no key while the windows one does.

fail2

Any help on this issue would be great.

@lsantos124 commented on GitHub (Feb 21, 2018): I am using ReaderFactory to try to decompress a Unix-created .gz archive and it does not seem to work. It seems to be the same issue as Felix's issue. I noticed that when I uncompressed it through 7zip and then rezipped it into a .gz file on Windows, that it was able to be unzipped. I have attached the windows created .gz and the unix created .gz. [windows_created.bson.gz](https://github.com/adamhathcock/sharpcompress/files/1744504/windows_created.bson.gz) [unix_created.bson.gz](https://github.com/adamhathcock/sharpcompress/files/1744505/unix_created.bson.gz) I am using the following code: ![fail](https://user-images.githubusercontent.com/11395887/36488344-2dea8692-16f1-11e8-96d1-5931c008619e.PNG) The unix_created .gz file fails at the archive.WriteToDirectory( .. ) line. Below shows that the unix_created archive shows no key while the windows one does. ![fail2](https://user-images.githubusercontent.com/11395887/36488462-82cc1eb4-16f1-11e8-893b-9d9e9fba4720.png) Any help on this issue would be great.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#93