Skip to content

EscherBSERecord fillFields() to return consumed bytes#1105

Merged
pjfanning merged 1 commit into
apache:trunkfrom
jmestwa-coder:bse-fillfields
Jun 3, 2026
Merged

EscherBSERecord fillFields() to return consumed bytes#1105
pjfanning merged 1 commit into
apache:trunkfrom
jmestwa-coder:bse-fillfields

Conversation

@jmestwa-coder
Copy link
Copy Markdown
Contributor

Summary

Restore the fillFields() contract in EscherBSERecord by returning the number of bytes actually consumed from the input stream rather than a reconstructed serialized size.

Problem

EscherBSERecord.fillFields() returned the embedded blip's getRecordSize(), which can differ from the number of bytes actually read when malformed records contain inconsistent size information.

This can cause parent containers to advance by an incorrect offset and mis-locate subsequent sibling records during parsing.

Fix

  • Return the actual number of bytes consumed (bytesRead) when calculating the value returned by fillFields().
  • Preserve the expected parser invariant that fillFields() reports consumed input bytes.

Test

  • Add a regression test covering a malformed EscherMetafileBlip whose cbSave value exceeds the data declared by the record length.
  • Verify that EscherBSERecord.fillFields() reports the record's actual on-disk length rather than an inflated reconstructed size.
  • Demonstrate that the previous behavior would over-report consumed bytes and cause parser offset drift.

Copy link
Copy Markdown
Member

@pjfanning pjfanning left a comment

Choose a reason for hiding this comment

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

lgtm

@pjfanning pjfanning merged commit 93aebfc into apache:trunk Jun 3, 2026
1 check passed
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.

2 participants