Failure to check upload filesize in wp_create_thumbnail() (1 post)

  1. rg
    Posted 9 years ago #

    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:
    Size:0 KB


    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;
    < }

Topic Closed

This topic has been closed to new replies.

About this Topic