return 0;
}
width = (width << 7) | (i & 0x7f);
+ /* maximum valid width for wbmp (although 127 may be a more accurate one) */
+ if (width > 2048) {
+ return 0;
+ }
} while (i & 0x80);
-
+
/* get height */
do {
i = php_stream_getc(stream);
return 0;
}
height = (height << 7) | (i & 0x7f);
+ /* maximum valid heigth for wbmp (although 127 may be a more accurate one) */
+ if (height > 2048) {
+ return 0;
+ }
} while (i & 0x80);
- /* maximum valid sizes for wbmp (although 127x127 may be a more accurate one) */
- if (!height || !width || height > 2048 || width > 2048) {
+ if (!height || !width) {
return 0;
}
-
+
if (!check) {
(*result)->width = width;
(*result)->height = height;
/* {{{ php_imagetype
detect filetype from first bytes */
-PHPAPI int php_getimagetype(php_stream * stream, char *filetype TSRMLS_DC)
+PHPAPI int php_getimagetype(php_stream * stream, char *filetype)
{
char tmp[12];
+ int twelve_bytes_read;
if ( !filetype) filetype = tmp;
if((php_stream_read(stream, filetype, 3)) != 3) {
}
/* AFTER ALL ABOVE FAILED */
- if (php_get_wbmp(stream, NULL, 1 TSRMLS_CC)) {
+ if (php_get_wbmp(stream, NULL, 1)) {
return IMAGE_FILETYPE_WBMP;
}
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Read error!");
+ if (!twelve_bytes_read) {
- if (php_get_xbm(stream, NULL TSRMLS_CC)) {
++ php_error_docref(NULL, E_NOTICE, "Read error!");
+ return IMAGE_FILETYPE_UNKNOWN;
+ }
+ if (php_get_xbm(stream, NULL)) {
return IMAGE_FILETYPE_XBM;
}
return IMAGE_FILETYPE_UNKNOWN;