Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ext/standard/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions ext/standard/tests/image/gh25964.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
GH-25964 (getimagesize(): WebP VP8/VP8L dimensions are accepted with an invalid signature)
--CREDITS--
kid-lxy
--FILE--
<?php
$webp = 'RIFF' . pack('V', 22) . 'WEBP'
. 'VP8 ' . pack('V', 10)
. "\x00\x00\x00"
. "\x9d\x01\x2b"
. "\xff\x3f\xff\x3f";
var_dump(getimagesizefromstring($webp));

$webp = 'RIFF' . pack('V', 22) . 'WEBP'
. 'VP8L' . pack('V', 10)
. "\x00"
. "\xff\xff\xff\xff"
. "\x00\x00\x00\x00\x00";
var_dump(getimagesizefromstring($webp));
?>
--EXPECT--
bool(false)
bool(false)
Loading