note 55340 added to function.imagecreatefromjpeg
| From: | miczimbett at gmail dot com | Date: | Sun, 31 Jul 2005 12:30:08 +0000 |
| Subject: | note 55340 added to function.imagecreatefromjpeg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92809@lists.php.net to get a copy of this message | ||
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;
}
}
----
Submitter IP: 64.246.30.37
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55340
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55340&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55340&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55340&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55340&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55340&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55340&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55340&report=yes
Search -- http://master.php.net/manage/user-notes.php