Skip to content

ext/gd: pack imageloadfont short-read test in native byte order#22416

Closed
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:gd-imageloadfont-test-endian
Closed

ext/gd: pack imageloadfont short-read test in native byte order#22416
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:gd-imageloadfont-test-endian

Conversation

@iliaal

@iliaal iliaal commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

The imageloadfont_short_read test packed the font header with pack('V4', ...) (little-endian), but imageloadfont() reads it as native-endian ints, so on big-endian hosts the byte-swapped values trip the INT_MAX overflow guard before the FLIPWORD fallback and the font is rejected. Packing with pack('i4', ...) keeps the header valid on both, fixing the PPC64 nightly failure.

@devnexen

Copy link
Copy Markdown
Member

@iliaal I would recommend to enable CI for PPC64 (look at the labels) since this is where the issue was from.

imageloadfont_short_read packed the font header with pack('V4', ...)
(little-endian), but imageloadfont() reads the header as native-endian
ints. On big-endian hosts (PPC64 nightly) the byte-swapped values
overflow the INT_MAX guard before the FLIPWORD fallback runs, so the
font is rejected and the test fails. Pack the fields with 'i' to keep
the header valid regardless of host endianness.
@iliaal iliaal force-pushed the gd-imageloadfont-test-endian branch from 59528b0 to a853ddf Compare June 24, 2026 10:47
@iliaal

iliaal commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

took a minute to figure out enabling ppc64 test, looks like fix is working there

@iliaal iliaal closed this in 5af5614 Jun 24, 2026
@iluuu1994

Copy link
Copy Markdown
Member

Thanks @iliaal!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants