oseawey / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

Bad handling of internet connection problems. #162

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. When we have internet connection problems, external images does not fully 
loaded with error like error reading file 
http://www.celebritywinereview.tv/wp-content/uploads/2010/12/IMG_9801.jpg from 
remote host: Operation timed out after 5000 milliseconds with 986700 out of 
1088018 bytes received
2. In cache we have partialy loaded image.
3. In next call we have an error "Unable to open image" (from cache)
and php error (gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file 
in \wp-content\themes\wp_theme\timthumb.php on line 372).

I think that script should delete partialy loaded image to prevent cache 
problem. And I think if file from cache have problem to load script must delete 
this cached file and trying to reloading file.
Also, as you can see 5 seconds timeout is not enough for all cases, so 
I think there is a good time to change line 
650: curl_setopt ($ch, CURLOPT_TIMEOUT, 5);
to
650: curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
(for example).

Using script v.1.24, windows 7

Original issue reported on code.google.com by mega...@gmail.com on 14 Feb 2011 at 9:53

GoogleCodeExporter commented 9 years ago
Some error is traped when MAX_FILE_SIZE reached. Partially loaded file existing 
in the cache.

Original comment by mega...@gmail.com on 14 Feb 2011 at 9:56

GoogleCodeExporter commented 9 years ago
Also I propose to pretend with @ all imagecreatefrom* calls to prevent warnings

    if (stripos ($mime_type, 'gif') !== false) {
        $image = @imagecreatefromgif ($src);
    } elseif (stripos ($mime_type, 'jpeg') !== false) {
        $image = @imagecreatefromjpeg ($src);
    } elseif (stripos ($mime_type, 'png') !== false) {
        $image = @imagecreatefrompng ($src);
    }

Original comment by mega...@gmail.com on 14 Feb 2011 at 10:21

GoogleCodeExporter commented 9 years ago
Version of timthumb with corrected issues in this and previous tickets. Works 
flawlesly with a connection problems I having there. Uses one 'goto' statement. 
I know this is completle wrong, but who cares?

Original comment by mega...@gmail.com on 14 Feb 2011 at 10:24

Attachments:

GoogleCodeExporter commented 9 years ago
Hi - this behaviour is intentional. It is there to stop possible dos attacks 
from being performed on your website. I can have increased the timeout on the 
curl which should help.

I have a couple of ideas for changing/ improving the code for the caching of 
external images which will allow me to increase the MAX_FILE_SIZE a bit. I am 
trying to strike a balance between good use and security. All the settings can 
be overriden in the defines at the top of the script.

Original comment by BinaryMoon on 14 Feb 2011 at 10:29

GoogleCodeExporter commented 9 years ago
So you say that living partially loaded files is intentional behavior? I don't 
think so, sorry.

Original comment by mega...@gmail.com on 15 Feb 2011 at 10:27

GoogleCodeExporter commented 9 years ago

Original comment by BinaryMoon on 7 May 2011 at 1:06