diff --git a/ext/standard/image.c b/ext/standard/image.c index 7544f8556cd2..503897ef88da 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -1144,10 +1144,18 @@ static struct php_gfxinfo *php_handle_webp(php_stream * stream) switch (format) { case ' ': + if (buf[11] != 0x9d || buf[12] != 0x01 || buf[13] != 0x2a) { + efree(result); + return NULL; + } result->width = buf[14] + ((buf[15] & 0x3F) << 8); result->height = buf[16] + ((buf[17] & 0x3F) << 8); break; case 'L': + if (buf[8] != 0x2f) { + efree(result); + return NULL; + } result->width = buf[9] + ((buf[10] & 0x3F) << 8) + 1; result->height = (buf[10] >> 6) + (buf[11] << 2) + ((buf[12] & 0xF) << 10) + 1; break; diff --git a/ext/standard/tests/image/gh25964.phpt b/ext/standard/tests/image/gh25964.phpt new file mode 100644 index 000000000000..42657052e6bb --- /dev/null +++ b/ext/standard/tests/image/gh25964.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-25964 (getimagesize(): WebP VP8/VP8L dimensions are accepted with an invalid signature) +--CREDITS-- +kid-lxy +--FILE-- + +--EXPECT-- +bool(false) +bool(false)