You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[io] check decoded image size against the frame header in OrganizedPointCloudCompression - #6535
OrganizedPointCloudCompression::decodePointCloud takes cloud_width and cloud_height from the frame header, while the disparity and color images it decodes get their dimensions from their own PNG headers. OrganizedConversion::convert then walks cloud_width x cloud_height pixels and indexes both images by that count, and the only checks that the sizes agree are asserts in organized_pointcloud_conversion.h, which release builds compile out. A frame whose header claims a larger cloud than its images hold, or whose color image is smaller than its disparity image, therefore reads past the end of the decoded heap buffers, and any untrusted stream can carry one, for example in the TCP client mode of openni_organized_compression. I confirmed it with AddressSanitizer: a 4x4 frame with its header patched to 64x64 gives a heap-buffer-overflow read at organized_pointcloud_conversion.h:406, and an 8x8 frame carrying a 4x4 color image gives one at line 426. The check lives in decodePointCloud, right after both images are decoded, because that is the one place that sees the header and the image sizes together; it rejects the frame when the disparity image does not hold cloud_width * cloud_height pixels (computed in 64 bit) or when a color image is present that is not a 1 or 3 channel image of that size. The new PCL.OrganizedDeCompressionImageSizeMismatch test in test_octree_compression.cpp covers both cases plus a valid round trip, and it is guarded by HAVE_PNG and HAVE_OPENNI like the instantiations in compression.cpp; it fails under ASan without the fix and passes with it.
Summary by CodeRabbit
Bug Fixes
Organized point-cloud decoding now rejects frames when decoded image dimensions do not match the dimensions in the frame header.
Decoding also rejects disparity or color data with invalid sizes, and color data with unsupported channel counts. This prevents malformed frames from being reconstructed as point clouds.
Tests
Added coverage for valid organized frames and frames with mismatched dimensions or image data.
No actionable comments were generated in the recent review.
Walkthrough
decodePointCloud now checks decoded image sizes and color channel counts against frame dimensions before point-cloud conversion. Guarded tests cover valid decoding and rejection of frames with mismatched dimensions or image sizes.
Changes: Organized point-cloud decoding
Layer / File(s)
Summary
Validate decoded images before conversion io/include/pcl/compression/impl/organized_pointcloud_compression.hpp, test/io/test_octree_compression.cpp
decodePointCloud rejects disparity or nonempty color data whose size does not match the frame dimensions. It also rejects color data with channel counts other than 1 or 3. Guarded tests cover a valid 4×4 frame and malformed dimensions or image sizes.
PointCloudLibrary/pcl#6518: Checks decoded disparity and color image sizes against frame dimensions in the same decode path.
PointCloudLibrary/pcl#6517: Validates PNG bit depth and color type in the decoder used by this decode path.
Merge Risk: Minimal · up to 2f4ab
This change makes decoding of malformed organized point-cloud frames fail cleanly instead of risking out-of-bounds reads. No remaining merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: decoded image size is now checked against the frame header in OrganizedPointCloudCompression. The raw summary confirms decodePointCloud validates disparity and color d…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: decoded image size is now checked against the frame header in OrganizedPointCloudCompression. The raw summary confirms decodePointCloud validates disparity and color dimensions against the header before reconstruction, and the tests cover the mismatch cases. The title is specific and concise, and it matches the objectives.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
This branch has not been deployed
No deployments
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
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.
OrganizedPointCloudCompression::decodePointCloud takes cloud_width and cloud_height from the frame header, while the disparity and color images it decodes get their dimensions from their own PNG headers. OrganizedConversion::convert then walks cloud_width x cloud_height pixels and indexes both images by that count, and the only checks that the sizes agree are asserts in organized_pointcloud_conversion.h, which release builds compile out. A frame whose header claims a larger cloud than its images hold, or whose color image is smaller than its disparity image, therefore reads past the end of the decoded heap buffers, and any untrusted stream can carry one, for example in the TCP client mode of openni_organized_compression. I confirmed it with AddressSanitizer: a 4x4 frame with its header patched to 64x64 gives a heap-buffer-overflow read at organized_pointcloud_conversion.h:406, and an 8x8 frame carrying a 4x4 color image gives one at line 426. The check lives in decodePointCloud, right after both images are decoded, because that is the one place that sees the header and the image sizes together; it rejects the frame when the disparity image does not hold cloud_width * cloud_height pixels (computed in 64 bit) or when a color image is present that is not a 1 or 3 channel image of that size. The new PCL.OrganizedDeCompressionImageSizeMismatch test in test_octree_compression.cpp covers both cases plus a valid round trip, and it is guarded by HAVE_PNG and HAVE_OPENNI like the instantiations in compression.cpp; it fails under ASan without the fix and passes with it.
Summary by CodeRabbit