Repository navigation
[io] compute LZF image sizes in 64 bit before checking the payload - #6504
Merged
mvieth merged 1 commit intoOct 25, 2026
Merged
Conversation
The PCLZF readers compare the uncompressed size from the file against width * height * bytes per pixel, with width and height also taken from the file. The product is computed in 32 bit and wraps, so a header with width 65537 and height 65536 accepts a payload sized for 65536 pixels. The depth reader then walks the full image and reads past the decompressed buffer, and the Bayer reader hands the full dimensions to the debayer, which does the same. Do the comparison in 64 bit so a wrapped product cannot match, and size the Bayer RGB buffer with std::size_t.
mvieth
approved these changes
Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AddressSanitizer, PCLZF depth image with width 65537 and height 65536:
The LZF image readers check the uncompressed size from the file against
getWidth () * getHeight () * N, but that product is computed in 32 bit. With 65537 x 65536 it wraps to 65536, so a small payload passes the check while the depth reader walks the full width and height and reads past the decompressed buffer. The Bayer reader hits the same thing insideDeBayer::debayerEdgeAware(debayer.cpp:441), and the RGB24 and YUV422 readers return a cloud whosewidth * heightno longer matches its size.Doing the comparison in 64 bit means a wrapped product can never match, so all eight
read/readOMPchecks reject the file before anything is decoded. I also sized the Bayer RGB buffer withstd::size_t, sincew * h * 3can still wrap after the check.PCL.LZFImageWrappedDimensionsin test_io.cpp covers all four readers: it hits the overflow above without the fix and passes with it, and the rest of test_io stays green.