Skip to content

ORC-624: [C++] Avoid unaligned trailer loads in LZO decompressor - #2709

Closed
wgtmac wants to merge 1 commit into
apache:mainfrom
wgtmac:ORC-624
Closed

ORC-624: [C++] Avoid unaligned trailer loads in LZO decompressor#2709
wgtmac wants to merge 1 commit into
apache:mainfrom
wgtmac:ORC-624

Conversation

@wgtmac

@wgtmac wgtmac commented Sep 2, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This PR replaces two potentially unaligned 16-bit trailer loads with an alignment-safe little-endian reader.

It also adds a long-distance match test covering the previously untested 0x10 LZO command path. This is a focused replacement for the LZO portion of #496, which was closed without merging.

Why are the changes needed?

The LZO input pointer advances byte by byte and is not guaranteed to be 2-byte aligned. Dereferencing it as uint16_t* or int16_t* is undefined behavior and is reported by UBSan.

How was this patch tested?

cmake --build build --target orc-test -j8
cd build/c++/test
./orc-test --gtest_filter='TestDecompression.testLzoLong:TestDecompression.testLzoLongDistanceMatch:TestDecompression.testLzoOverflow:TestDecompression.testLzoTruncatedStopCommand'

All four tests passed. The existing long test covers the 0x20 command path, and the new test covers the 0x10 path.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (GPT-5)

Decode 16-bit LZO trailers in little-endian order without dereferencing unaligned pointers.

@ffacs ffacs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luffy-zh luffy-zh closed this in 6d0d539 Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants