Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

Fixed parsing of non-regular files #2

Merged
merged 1 commit into from Sep 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/getID3/getid3_handler.php
Expand Up @@ -84,7 +84,17 @@ protected function fread($bytes) {
if (!getid3_lib::intValueSupported($pos)) {
throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
}
return fread($this->getid3->fp, $bytes);

// System fread function may return less data than requested in case the file is not a regular local file.
// See http://php.net/manual/en/function.fread.php. Call it repeatedly in a loop if that is the case.
$contents = '';
do {
$part = fread($this->getid3->fp, $bytes);
$partLength = strlen($part);
$bytes -= $partLength;
$contents .= $part;
} while ($bytes > 0 && $partLength > 0);
return $contents;
}

protected function fseek($bytes, $whence=SEEK_SET) {
Expand Down