From: Dan Mattern Date: Mon, 19 Feb 2018 22:59:17 +0000 (-0500) Subject: GD zero filesize error X-Git-Tag: 1.31.0-rc.0~568 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=32ae7651b8f6ae105d967873f53ab7a5cd228026;p=lhc%2Fweb%2Fwiklou.git GD zero filesize error Checking if the filesize is zero before passing to GD. This can result in a fatal error. Bug: T182387 Change-Id: I26a24286f3035f233de682caed21a8e8c2d5aaad --- diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index 712906e0e7..b88a34dcad 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -440,6 +440,14 @@ class BitmapHandler extends TransformationalImageHandler { return $this->getMediaTransformError( $params, $errMsg ); } + if ( filesize( $params['srcPath'] ) === 0 ) { + $err = "Image file size seems to be zero."; + wfDebug( "$err\n" ); + $errMsg = wfMessage( 'thumbnail_image-size-zero', $params['srcPath'] )->text(); + + return $this->getMediaTransformError( $params, $errMsg ); + } + $src_image = call_user_func( $loader, $params['srcPath'] ); $rotation = function_exists( 'imagerotate' ) && !isset( $params['disableRotation'] ) ? diff --git a/languages/i18n/en.json b/languages/i18n/en.json index b710762d3b..bcf0ec5704 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2761,6 +2761,7 @@ "thumbnail_dest_directory": "Unable to create destination directory", "thumbnail_image-type": "Image type not supported", "thumbnail_gd-library": "Incomplete GD library configuration: Missing function $1", + "thumbnail_image-size-zero": "Image file size seems to be zero.", "thumbnail_image-missing": "File seems to be missing: $1", "thumbnail_image-failure-limit": "There have been too many recent failed attempts ($1 or more) to render this thumbnail. Please try again later.", "import": "Import pages", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 6a071ed8f6..852d3eb6d5 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2958,6 +2958,7 @@ "thumbnail_image-type": "This is the parameter 1 of the message {{msg-mw|thumbnail error}}", "thumbnail_gd-library": "This is the parameter 1 of the message {{msg-mw|thumbnail error}}.\n*$1 is a function name of the GD library", "thumbnail_image-missing": "This is the parameter 1 of the message {{msg-mw|thumbnail error}}.\n*$1 is the path incl. filename of the missing image", + "thumbnail_image-size-zero": "This is the parameter 1 of the message {{msg-mw|thumbnail error}}.\n*$1 is the path incl. filename of the image with zero size", "thumbnail_image-failure-limit": "Used as $1 in {{msg-mw|Thumbnail error}}.\n\nParameters:\n* $1 - the maximum allowed number of failed attempts", "import": "The title of the special page [[Special:Import]];", "import-summary": "{{doc-specialpagesummary|import}}",