Skip to content

[io] check decoded image size against the frame header in OrganizedPointCloudCompression - #6535

Open
aysha-afrah26 wants to merge 1 commit into
PointCloudLibrary:masterfrom
aysha-afrah26:organized-decode-image-size
Open

aysha-afrah26 wants to merge 1 commit into
PointCloudLibrary:masterfrom
aysha-afrah26:organized-decode-image-size

Conversation

@aysha-afrah26

@aysha-afrah26 aysha-afrah26 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c73dc071-54a4-4708-8cb4-5c0634d71f3c
Commits

Reviewing files that changed from the base of the PR and between fd39f32 and 2f4ab53.

Files selected for processing: 2

  • io/include/pcl/compression/impl/organized_pointcloud_compression.hpp
  • test/io/test_octree_compression.cpp

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
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.

1 participant