Signed-off-by: Jerome Jutteau <jerome@jutteau.fr>
*/
function jirafeau_md5_outside($file_path)
{
*/
function jirafeau_md5_outside($file_path)
{
- $size = filesize($file_path);
- if ($size === false) {
- $size = 0;
- }
$handle = fopen($file_path, "r");
if ($handle === false) {
return false;
}
$handle = fopen($file_path, "r");
if ($handle === false) {
return false;
}
+ $size = filesize($file_path);
+ if ($size === false) {
+ goto err;
+ }
$first = fread($handle, 64);
if ($first === false) {
$first = fread($handle, 64);
if ($first === false) {
+ goto err;
+ }
+ if (fseek($handle, $size < 64 ? 0 : $size - 64) == -1) {
+ goto err;
- fseek($handle, $size < 64 ? 0 : $size - 64);
$last = fread($handle, 64);
$last = fread($handle, 64);
+ if ($last === false) {
+ goto err;
+ }
+ $out = md5($first . $last . $size);
+ err:
- return md5($first . $last . $size);