Skip to content

282 binaryreferencetraverser bounds check for variable length members#286

Merged
hg-ms merged 3 commits into
mainfrom
282-binaryreferencetraverser-bounds-check-for-variable-length-members
Jun 30, 2026
Merged

282 binaryreferencetraverser bounds check for variable length members#286
hg-ms merged 3 commits into
mainfrom
282-binaryreferencetraverser-bounds-check-for-variable-length-members

Conversation

@hg-ms

@hg-ms hg-ms commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

fixes #282

Serializer + Store required

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #282 by adding bounds-checked traversal paths to prevent variable-length member corruption from driving out-of-bounds memory reads during reference iteration, converting potential hard JVM crashes into BinaryPersistenceExceptions.

Changes:

  • Added a bounds-aware apply(address, bound, acceptor) default method to BinaryReferenceTraverser and a bounds-checked iterateReferences(address, bound, traversers, acceptor) overload.
  • Introduced validateVariableLengthBound(...) and updated variable-length traversers to validate list byte lengths against a provided bound.
  • Updated complex variable-length traversal to validate list byte length before iterating elements, and fixed a spelling typo (“truely” → “truly”).
Comments suppressed due to low confidence (1)

persistence/binary/src/main/java/org/eclipse/serializer/persistence/binary/types/BinaryReferenceTraverser.java:1379

  • In InlinedComplexType, listBound is computed from the validated list byte length, but the method returns a (end of iterated elements). If elementCount is corrupted too small, this returns a cursor inside the list, causing subsequent member traversers to interpret remaining element bytes as following fields. Returning the validated listBound keeps the cursor aligned with the list’s declared length.
			// return resulting address for recursive continued use
			return a;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@hg-ms hg-ms requested a review from fh-ms June 29, 2026 12:06
@hg-ms hg-ms merged commit 719f47e into main Jun 30, 2026
19 checks passed
@hg-ms hg-ms deleted the 282-binaryreferencetraverser-bounds-check-for-variable-length-members branch June 30, 2026 04:40
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.

BinaryReferenceTraverser: bounds check for variable-length members

3 participants