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

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

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/28

State: closed
Merged: Yes


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.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/28 **State:** closed **Merged:** Yes --- 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.
claunia added the pull-request label 2026-01-29 22:17:37 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#797