Skip to content

[io] Avoid 32-bit overflow in ASCIIReader buffer sizing - #6487

Merged
mvieth merged 2 commits into
PointCloudLibrary:masterfrom
KoksalBerkay:fix-ascii-reader-size-overflow
Oct 6, 2026
Merged

mvieth merged 2 commits into
PointCloudLibrary:masterfrom
KoksalBerkay:fix-ascii-reader-size-overflow

Conversation

@KoksalBerkay

Copy link
Copy Markdown
Contributor

Fixes #6483.

ASCIIReader calculates buffer sizes using 32-bit multiplication before converting the result to std::size_t. On 64-bit systems, large inputs can therefore produce a truncated buffer size.

Promote one operand to std::size_t before multiplication in both the initial allocation and the final resize. This follows the approach approved in the issue and used by PLYReader.

Add a regression test that supplies synthetic large metadata through readHeader() and exercises the real read() method. The expected size exceeds vector::max_size(), allowing the test to check rejection without allocating a huge buffer.

Validation:

  • The regression fails with the original implementation and passes with the fix.
  • All 47 tests in the I/O executable pass.
  • All 11 configured I/O CTest entries pass.
  • git diff --check passes.

Tested on arm64 macOS with 64-bit std::size_t. This change does not add overflow checks for 32-bit systems.

Comment thread io/src/ascii_io.cpp Outdated
Comment thread test/io/test_io.cpp Outdated

@mvieth mvieth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@mvieth mvieth added module: io changelog: fix Meta-information for changelog generation labels Oct 6, 2026
@mvieth
mvieth merged commit c471988 into PointCloudLibrary:master Oct 6, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: fix Meta-information for changelog generation module: io

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variant analysis: 1 unfixed sibling safety gap in pcl

3 participants