Skip to content

Accept small section size overshoot and zero-fill the tail - #47

Merged
mahach666 merged 1 commit into
mainfrom
fix/12-classes-overshoot
Nov 16, 2026
Merged

mahach666 merged 1 commit into
mainfrom
fix/12-classes-overshoot

Conversation

@mahach666

Copy link
Copy Markdown
Contributor

Fixes #12

Problem

Some AC1032 drawings declare AcDb:Classes as 89,091 bytes while its three pages can hold 89,088 bytes (3 × 29,696). Every page decompresses to exactly the page size and all checksums pass, but the size guard in R2004Container.ReadSection rejected the section before reading any page. The same guard also makes CrcVerification_PassesOnRealFiles fail on those files.

Change

  • Accept a declared size that exceeds the page budget by at most 256 bytes, zero-fill the uncovered tail and report a diagnostic through the document's Diagnostics.
  • Keep rejecting a declared size far beyond the page budget before allocating the result buffer, so the hardening against over-allocation is unchanged.
  • DwgDocument.ReadSection and the internal section reads now pass the diagnostics collector to the container; synthetic container callers can supply their own callback.

Tests

  • A one-page section declaring 3 bytes more than its page holds is accepted, the tail is zero-filled and a diagnostic is reported.
  • A section declaring 257 bytes more than its page holds still throws.
  • The existing array-limit and document-budget tests are unchanged and still pass.

Verification

  • dotnet build DwgIO.slnx -c Release: succeeded.
  • dotnet test DwgIO.slnx -c Release --no-build: 70 passed, 7 fixture tests skipped, 0 failed on net8.0 and net10.0.
  • CrcVerification_PassesOnRealFiles against 668 supported drawings (AC1024/AC1027/AC1032): passed on net8.0 and net10.0, including the two drawings that previously failed with the AcDb:Classes size error.

Some writers declare a section a few bytes larger than its pages can hold. The size guard rejected such sections even though every page decompressed and verified, which made AcDb:Classes unreadable in a few AC1032 drawings.

Allow up to 256 bytes beyond the page budget, zero-fill the uncovered tail and report a diagnostic through the document. A declared size far beyond the budget is still rejected before allocation.
@mahach666
mahach666 merged commit c195b2c into main Nov 16, 2026
4 checks 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.

AcDb:Classes is rejected when its declared size is a few bytes larger than its pages hold

1 participant