[PR #299] [MERGED] XZ: fix variable-length integers decoding #950

Closed
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/299
Author: @frabar666
Created: 9/16/2017
Status: Merged
Merged: 9/17/2017
Merged by: @adamhathcock

Base: masterHead: fix-vli-decoding


📝 Commits (1)

  • f2ed1df XZ: fix variable-length integers decoding

📊 Changes

2 files changed (+10 additions, -1 deletions)

View changed files

📝 src/SharpCompress/Compressors/Xz/MultiByteIntegers.cs (+1 -1)
📝 tests/SharpCompress.Test/Xz/XZIndexTests.cs (+9 -0)

📄 Description

The ReadXZInteger extension method reads VLIs in XZ streams. It reads the right number of bytes, but does not return the correct value for multi-byte VLIs (>= 128) because an increment is missing.

This PR adds the missing increment, with a unit test (based on XZIndex). The fix matches the reference Java implementation.

I see two cases where a valid XZ file could previously not be read:

  • XZ file with an index containing >= 128 records (AFAIK indexes aren't that common),
  • block filter with >= 128 bytes of properties (seems unlikely).

🔄 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/299 **Author:** [@frabar666](https://github.com/frabar666) **Created:** 9/16/2017 **Status:** ✅ Merged **Merged:** 9/17/2017 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `fix-vli-decoding` --- ### 📝 Commits (1) - [`f2ed1df`](https://github.com/adamhathcock/sharpcompress/commit/f2ed1df7bf793bb19b7fc6d79ff8551588fc101d) XZ: fix variable-length integers decoding ### 📊 Changes **2 files changed** (+10 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/SharpCompress/Compressors/Xz/MultiByteIntegers.cs` (+1 -1) 📝 `tests/SharpCompress.Test/Xz/XZIndexTests.cs` (+9 -0) </details> ### 📄 Description The `ReadXZInteger` extension method reads VLIs in XZ streams. It reads the right number of bytes, but does not return the correct value for multi-byte VLIs (>= 128) because an increment is missing. This PR adds the missing increment, with a unit test (based on XZIndex). The fix matches the [reference Java implementation](https://git.tukaani.org/?p=xz-java.git;a=blob;f=src/org/tukaani/xz/common/DecoderUtil.java;h=77ba4413e71ef37f73b29d8dca96231c1c75240a;hb=HEAD#l106). I see two cases where a valid XZ file could previously not be read: - XZ file with an index containing >= 128 records (AFAIK indexes aren't that common), - block filter with >= 128 bytes of properties (seems unlikely). --- <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#950