Skip to content

Handle oversized uint32 offsets in QuillContents descriptors#1077

Open
metsw24-max wants to merge 1 commit into
apache:trunkfrom
metsw24-max:hpbf-quillcontents-overflow-guard
Open

Handle oversized uint32 offsets in QuillContents descriptors#1077
metsw24-max wants to merge 1 commit into
apache:trunkfrom
metsw24-max:hpbf-quillcontents-overflow-guard

Conversation

@metsw24-max
Copy link
Copy Markdown
Contributor

QuillContents reads bit descriptor from/len fields as uint32 values from Publisher .pub files, but previously narrowed them directly to int via a plain cast before validation.

A crafted descriptor with values larger than Integer.MAX_VALUE could therefore wrap to negative values and only fail later inside IOUtils.safelyClone(...) with a generic "Invalid offset\\length specified" error that lost the original unsigned value.

This change validates the uint32 values before narrowing:

  • oversized offsets now throw RecordFormatException carrying the original uint32 value
  • lengths are gated through IOUtils.safelyAllocateCheck(...) before casting

Adds regression tests that build minimal in-memory .pub containers with crafted descriptor values and verify that oversized uint32 fields are rejected during QuillContents parsing.

Tested:

  • existing HPBF tests
  • new TestQuillContentsOverflow regression tests

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