]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.6'
authorChristoph M. Becker <cmb@php.net>
Thu, 23 Jul 2015 16:40:54 +0000 (18:40 +0200)
committerChristoph M. Becker <cmb@php.net>
Thu, 23 Jul 2015 16:40:54 +0000 (18:40 +0200)
* PHP-5.6:
  Fix #70052: getimagesize() fails for very large and very small WBMP

Conflicts:
ext/standard/image.c

1  2 
ext/standard/image.c

index edb0d50ea3ee169e3d5f6de7fb67e85f1679375a,a240493677da8eb596d58e82957a7603a7a7cbf9..378423917e6b34ad3bd5818e74741740c3895690
@@@ -969,8 -969,12 +969,12 @@@ static int php_get_wbmp(php_stream *str
                        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;
@@@ -1220,9 -1227,10 +1227,10 @@@ PHP_FUNCTION(image_type_to_extension
  
  /* {{{ 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;