[PR #28] [MERGED] Fixed bugs related to handling of .tar archives with long names #793

Open
opened 2026-01-29 22:17:36 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/28
Author: @Strachu
Created: 12/16/2014
Status: Merged
Merged: 12/16/2014
Merged by: @adamhathcock

Base: masterHead: tar_fix


📝 Commits (2)

  • 2e533f9 Fixed handling of ustar tar files with long names.
  • 8fcb0cb Fixed bug causing entries of non-ustar archive being after one with very long name to be discarded

📊 Changes

5 files changed (+39 additions, -9 deletions)

View changed files

📝 SharpCompress.Test/Tar/TarArchiveTests.cs (+23 -3)
📝 SharpCompress/Archive/Tar/TarArchive.cs (+15 -5)
📝 SharpCompress/Common/Tar/Headers/TarHeader.cs (+1 -1)
TestArchives/Archives/ustar with long names.tar (+0 -0)
📝 TestArchives/Archives/very long filename.tar (+0 -0)

📄 Description

I have fixed 2 bugs related to reading of .tar archives.

  1. The "magic" for ustar archive is "ustar" + null character instead of "ustar " (note the following space). Before the fix the code was not recognizing the format correctly, making issues when the archive had very long name.
  2. When the archive (now not in "ustar" format) had very long names, the entries which were after the one with very long name were not loaded.
    It was caused by 2 issues:
    1. method entry.WriteTo() called during loading internally caused the marking of the archive as fully loaded without loading entries after the one currently read.
    2. because entries use shared stream for reading, reading the name of entry is changing the current position of the stream without restoring previous position.

I have attached test cases for these bugs, they fail without my fixes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/28 **Author:** [@Strachu](https://github.com/Strachu) **Created:** 12/16/2014 **Status:** ✅ Merged **Merged:** 12/16/2014 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `tar_fix` --- ### 📝 Commits (2) - [`2e533f9`](https://github.com/adamhathcock/sharpcompress/commit/2e533f9fb5f2668eb2a092bff0a33ca8cd05a7fe) Fixed handling of ustar tar files with long names. - [`8fcb0cb`](https://github.com/adamhathcock/sharpcompress/commit/8fcb0cb7a2f7f5f197c588c5b1773eddd4e944f6) Fixed bug causing entries of non-ustar archive being after one with very long name to be discarded ### 📊 Changes **5 files changed** (+39 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `SharpCompress.Test/Tar/TarArchiveTests.cs` (+23 -3) 📝 `SharpCompress/Archive/Tar/TarArchive.cs` (+15 -5) 📝 `SharpCompress/Common/Tar/Headers/TarHeader.cs` (+1 -1) ➕ `TestArchives/Archives/ustar with long names.tar` (+0 -0) 📝 `TestArchives/Archives/very long filename.tar` (+0 -0) </details> ### 📄 Description I have fixed 2 bugs related to reading of .tar archives. 1. The "magic" for ustar archive is "ustar" + null character instead of "ustar " (note the following space). Before the fix the code was not recognizing the format correctly, making issues when the archive had very long name. 2. When the archive (now not in "ustar" format) had very long names, the entries which were after the one with very long name were not loaded. It was caused by 2 issues: 1. method entry.WriteTo() called during loading internally caused the marking of the archive as fully loaded without loading entries after the one currently read. 2. because entries use shared stream for reading, reading the name of entry is changing the current position of the stream without restoring previous position. I have attached test cases for these bugs, they fail without my fixes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:17:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#793