From 59528b0bec4111fbb7185aa670938e3178a7e018 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 23 Jun 2026 11:12:53 -0400 Subject: [PATCH] ext/gd: pack imageloadfont short-read test in native byte order 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. --- ext/gd/tests/imageloadfont_short_read.phpt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/gd/tests/imageloadfont_short_read.phpt b/ext/gd/tests/imageloadfont_short_read.phpt index 5a7f6a14c9bb..406c64b99595 100644 --- a/ext/gd/tests/imageloadfont_short_read.phpt +++ b/ext/gd/tests/imageloadfont_short_read.phpt @@ -7,7 +7,9 @@ gd /* A user-space wrapper returns one byte per read, so php_stream_read() hands * imageloadfont()'s header loop a short read on every iteration. The header * (4 ints) plus a single 1x1 glyph byte form a valid font, which only loads - * when each short read lands at the correct byte offset. */ + * when each short read lands at the correct byte offset. imageloadfont() reads + * the header as native-endian ints, so pack the fields with 'i' (not 'V') to + * keep the font valid on big-endian hosts too. */ class drip { public $context; @@ -16,7 +18,7 @@ class drip public function stream_open($path, $mode, $options, &$opened): bool { - $this->data = pack('V4', 1, 32, 1, 1) . "\x00"; + $this->data = pack('i4', 1, 32, 1, 1) . "\x00"; return true; }