diff --git a/NEWS b/NEWS index 0f39334377e0..8cead60815d1 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,8 @@ PHP NEWS incremental flush). (David Carlier) . Fixed bug GH-22395 (base_convert() outputs at most 64 characters). (Weilin Du) + . Fixed integer overflow in getimagesize() and getimagesizefromstring() when + parsing an IFF chunk with a size of INT_MAX. (David Carlier, Weilin Du) 02 Jul 2026, PHP 8.4.23 diff --git a/ext/standard/image.c b/ext/standard/image.c index 15761364c341..4709b93d0a5a 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -875,6 +875,9 @@ static struct gfxinfo *php_handle_iff(php_stream * stream) return NULL; } if ((size & 1) == 1) { + if (size == INT_MAX) { + return NULL; + } size++; } if (chunkId == 0x424d4844) { /* BMHD chunk */ diff --git a/ext/standard/tests/image/getimagesizefromstring_iff_overflow.phpt b/ext/standard/tests/image/getimagesizefromstring_iff_overflow.phpt new file mode 100644 index 000000000000..f6fdea9d8e6b --- /dev/null +++ b/ext/standard/tests/image/getimagesizefromstring_iff_overflow.phpt @@ -0,0 +1,24 @@ +--TEST-- +getimagesizefromstring() IFF chunk size integer overflow (GH-getimagesize_oflow) +--CREDITS-- +Alexandre Daubois +--FILE-- + +--CLEAN-- + +--EXPECT-- +bool(false) +bool(false)