Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#2030 closed defect (bug) (fixed)

Failure to check upload filesize in wp_create_thumbnail()

Reported by: rg Owned by:
Milestone: Priority: normal
Severity: normal Version: 1.5.2
Component: Administration Keywords: thumbnail admin-functions.php
Focuses: Cc:


the wp_create_thumbnail() function in admin_functions.php fails to check filesize of $file before trying to mainpulate $file as an image. If $file is an empty file (because user typoed the filename during upload), this error message is displayed:

Warning: getimagesize(): Read error! in /home/rg/public_html/wordpress/wp-admin/admin-functions.php on line 198

Warning: getimagesize(): Read error! in /home/rg/public_html/wordpress/wp-admin/admin-functions.php on line 223

Warning: Division by zero in /home/rg/public_html/wordpress/wp-admin/admin-functions.php on line 241

Warning: imagecreatetruecolor(): Invalid image dimensions in /home/rg/public_html/wordpress/wp-admin/admin-functions.php on line 245 File uploaded!

Your file ifoo.jpg was uploaded successfully!

Here’s the code to display it:


Image Details: Name:ifoo.jpg Size:0 KB Type:application/octet-stream

division by zero, oh the shame !

this patch catches the condition and reports a useful error:

< if (filesize($file) == 0)
< {
< $error = __('Uploaded file is 0Kb. Thumbnail not created.');
< return $error;
< }

Change History (1)

#1 @skeltoac
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

wp_handle_upload() in 2.0 checks this.

Note: See TracTickets for help on using tickets.