note 55340 deleted from function.imagecreatefromjpeg by cmb
| From: | cmb@php.net | Date: | Sun, 11 Dec 2016 11:21:53 +0000 |
| Subject: | note 55340 deleted from function.imagecreatefromjpeg by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208516@lists.php.net to get a copy of this message | ||
Note Submitter: miczimbett at gmail dot com
----
the check_jpeg function listed above has a small "bug" when u set $fix=true... after the
fix, the function does not close the file... and the imagecreatefromjpeg would still crash on an
open file.
//# [070203]
//# check for jpeg file header and footer - also try to fix it
function check_jpeg($f, $fix=false ){
if ( false !== (@$fd = fopen($f, 'r+b' )) ){
if (fread($fd,2)==chr(255).chr(216) ){
fseek ( $fd, -2, SEEK_END );
if ( fread($fd,2)==chr(255).chr(217) ){
fclose($fd);
return true;
}else{
if ($fix && fwrite($fd,chr(255).chr(217)) ){
fclose($fd);
return true;
}
fclose($fd);
return false;
}
} else {
fclose($fd);
return false;
}
} else {
return false;
}
}