Skip to content

Reject oversized 32-bit fields in parsers, and build for armv7 - #81

Merged
colemancda merged 13 commits into
masterfrom
fix/32-bit-parsers
Dec 3, 2026
Merged

colemancda merged 13 commits into
masterfrom
fix/32-bit-parsers

Conversation

@colemancda

Copy link
Copy Markdown
Member

Graphite also runs on 32-bit PowerPC Linux, where Int is 32 bits. Several parsers converted untrusted UInt32 fields with Int(...), which traps there for values of 0x80000000 and above. This is the parser half of the 32-bit audit; the arithmetic half was #80.

Changes

  • 32-bit fields in resource forks, AppleDouble, sfnt, AIFF, snd , pictures, color cursors, icon families and classic descriptor data are clamped, so the existing bounds checks reject them with each parser's usual error. Sums and products that could still overflow are rewritten.
  • Counts that were already tolerated (AIFF frame counts, loop points, an icns total length past the data) still use the data there is.
  • Short rows: Cursor(crsr:) and ColorIcon(cicn:) indexed out of bounds, on any CPU, when rowBytes or maskRowBytes was too small for the width. They now throw a parameter error.
  • Denormals: Extended80.doubleValue read them as zero on 32-bit ARM, where Double.leastNonzeroMagnitude is the smallest normal number.
  • CI: a new job cross-compiles the package and its tests for armv7 with the community SDK from swift-embedded-linux/armhf-debian, pinned by SHA-256. It leaves out FreeType and the Cacao host, renderer and demo, and it does not run the tests.

Testing

  • swift test passes on macOS after rebasing onto master.
  • Before the rebase, a trimmed package (core, files, resources, events, automation, 2D, text and sound; FreeType off) passed all 614 tests on armv7 under QEMU. The new oversized-field and short-row tests all trapped there against the old parser sources.
  • The CI job's destination and build steps pass locally in an arm64 Swift 6.4.3 container.
  • Not tested on PowerPC or any big-endian target.

@colemancda
colemancda merged commit e63c458 into master Dec 3, 2026
3 of 4 checks passed
@colemancda
colemancda deleted the fix/32-bit-parsers branch December 3, 2026 21:34
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