Skip to content

Commit a853ddf

Browse files
committed
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.
1 parent 087a08d commit a853ddf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ext/gd/tests/imageloadfont_short_read.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ gd
77
/* A user-space wrapper returns one byte per read, so php_stream_read() hands
88
* imageloadfont()'s header loop a short read on every iteration. The header
99
* (4 ints) plus a single 1x1 glyph byte form a valid font, which only loads
10-
* when each short read lands at the correct byte offset. */
10+
* when each short read lands at the correct byte offset. imageloadfont() reads
11+
* the header as native-endian ints, so pack the fields with 'i' (not 'V') to
12+
* keep the font valid on big-endian hosts too. */
1113
class drip
1214
{
1315
public $context;
@@ -16,7 +18,7 @@ class drip
1618

1719
public function stream_open($path, $mode, $options, &$opened): bool
1820
{
19-
$this->data = pack('V4', 1, 32, 1, 1) . "\x00";
21+
$this->data = pack('i4', 1, 32, 1, 1) . "\x00";
2022
return true;
2123
}
2224

0 commit comments

Comments
 (0)