Skip to content

Validate EMR_EXTCREATEPEN style entry count before allocation#1117

Open
jmestwa-coder wants to merge 1 commit into
apache:trunkfrom
jmestwa-coder:extcreatepen-allocation-validation
Open

Validate EMR_EXTCREATEPEN style entry count before allocation#1117
jmestwa-coder wants to merge 1 commit into
apache:trunkfrom
jmestwa-coder:extcreatepen-allocation-validation

Conversation

@jmestwa-coder

Copy link
Copy Markdown
Contributor

Summary

Validate the EMR_EXTCREATEPEN style entry count before allocating the dash pattern array.

Changes

  • Add HemfPicture.safelyAllocateCheck(numStyleEntries) before allocating the dash pattern array.
  • Reuse the existing HEMF allocation validation mechanism already used in related parser paths.
  • Reject oversized style entry counts before attempting memory allocation.

Why

  • numStyleEntries is read from EMF input and directly controls array allocation size.
  • A malformed record can request an excessively large allocation, leading to resource exhaustion or allocation failures.
  • This change ensures allocation limits are enforced consistently across HEMF record parsers.

Impact

  • No behavior change for valid EMF files.
  • Oversized or malformed inputs now fail through the existing validation path instead of attempting allocation.
  • Aligns EMR_EXTCREATEPEN with the recent HEMF allocation-hardening updates.

@jmestwa-coder jmestwa-coder force-pushed the extcreatepen-allocation-validation branch from 30dc72e to efdd43b Compare June 4, 2026 18:31
@pjfanning

Copy link
Copy Markdown
Member

duplicate of #1113

I'll also point you to #1113 (comment)

I probably won't merge many more changes like this and won't even read them.

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