[PR #300] [MERGED] XZ: fix padding issues #952

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

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/300
Author: @frabar666
Created: 9/17/2017
Status: Merged
Merged: 9/17/2017
Merged by: @adamhathcock

Base: masterHead: fix-padding


📝 Commits (4)

  • f2ed1df XZ: fix variable-length integers decoding
  • 27a01f0 XZ: fix block and index padding issues
  • c80afa9 cleanup in XZStreamTests
  • b1fbae8 Merge branch 'master' into fix-padding

📊 Changes

6 files changed (+180 additions, -11 deletions)

View changed files

📝 src/SharpCompress/Compressors/Xz/XZBlock.cs (+4 -4)
📝 src/SharpCompress/Compressors/Xz/XZIndex.cs (+3 -3)
📝 tests/SharpCompress.Test/Xz/XZBlockTests.cs (+25 -0)
📝 tests/SharpCompress.Test/Xz/XZIndexTests.cs (+52 -2)
📝 tests/SharpCompress.Test/Xz/XZStreamTests.cs (+24 -2)
📝 tests/SharpCompress.Test/Xz/XZTestsBase.cs (+72 -0)

📄 Description

SkipPadding in XZBlock and XZIndex did not always skip the right number of bytes:

  • block padding size computation used decompressed instead of compressed bytes,
  • and both were wrong for even numbers of bytes (skipped 1 when they should have skipped 3, and vice-versa).

This PR fixes both SkipPadding methods, resolves #289 and resolves #296.
I added unit tests using two new inline XZ files (an empty one, and one with 2 blocks), in order to test more cases.

Note that this relies on my previous PR #299: I created a new branch on top of the one I used for the previous PR, not sure if that was the right way to go...


🔄 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/300 **Author:** [@frabar666](https://github.com/frabar666) **Created:** 9/17/2017 **Status:** ✅ Merged **Merged:** 9/17/2017 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `fix-padding` --- ### 📝 Commits (4) - [`f2ed1df`](https://github.com/adamhathcock/sharpcompress/commit/f2ed1df7bf793bb19b7fc6d79ff8551588fc101d) XZ: fix variable-length integers decoding - [`27a01f0`](https://github.com/adamhathcock/sharpcompress/commit/27a01f0ab79b3da2d12300147213871a601c6048) XZ: fix block and index padding issues - [`c80afa9`](https://github.com/adamhathcock/sharpcompress/commit/c80afa92f59dcc318dfefcfbccb26afb74438d0b) cleanup in XZStreamTests - [`b1fbae8`](https://github.com/adamhathcock/sharpcompress/commit/b1fbae8e67604b5a62b598f3def65c0bbd074901) Merge branch 'master' into fix-padding ### 📊 Changes **6 files changed** (+180 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Compressors/Xz/XZBlock.cs` (+4 -4) 📝 `src/SharpCompress/Compressors/Xz/XZIndex.cs` (+3 -3) 📝 `tests/SharpCompress.Test/Xz/XZBlockTests.cs` (+25 -0) 📝 `tests/SharpCompress.Test/Xz/XZIndexTests.cs` (+52 -2) 📝 `tests/SharpCompress.Test/Xz/XZStreamTests.cs` (+24 -2) 📝 `tests/SharpCompress.Test/Xz/XZTestsBase.cs` (+72 -0) </details> ### 📄 Description `SkipPadding` in `XZBlock` and `XZIndex` did not always skip the right number of bytes: - block padding size computation used decompressed instead of compressed bytes, - and both were wrong for even numbers of bytes (skipped 1 when they should have skipped 3, and vice-versa). This PR fixes both `SkipPadding` methods, resolves #289 and resolves #296. I added unit tests using two new inline XZ files (an empty one, and one with 2 blocks), in order to test more cases. Note that this relies on my previous PR #299: I created a new branch on top of the one I used for the previous PR, not sure if that was the right way to go... --- <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:18:20 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#952