Skip to content

Commit

Permalink
JamesHeinrich#418 fread length error in XMP
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHeinrich committed Aug 8, 2023
1 parent 9993caa commit cba30f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion getid3/getid3.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class getID3
*/
protected $startup_warning = '';

const VERSION = '1.9.22-202305291732';
const VERSION = '1.9.22-202308081917';
const FREAD_BUFFER_SIZE = 32768;

const ATTACHMENTS_NONE = false;
Expand Down
11 changes: 10 additions & 1 deletion getid3/module.tag.xmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,16 @@ public function _get_jpeg_header_data($filename)
$segdatastart = ftell($filehnd);

// Read the segment data with length indicated by the previously read size
$segdata = fread($filehnd, $decodedsize['size'] - 2);
// fread will complain about trying to read zero bytes: "fread(): Argument #2 ($length) must be greater than 0" -- https://github.com/JamesHeinrich/getID3/issues/418
if ($decodedsize['size'] > 2) {
$segdata = fread($filehnd, $decodedsize['size'] - 2);
} elseif ($decodedsize['size'] == 2) {
$segdata = '';
} else {
// invalid length
fclose($filehnd);
return false;
}

// Store the segment information in the output array
$headerdata[] = array(
Expand Down

0 comments on commit cba30f6

Please sign in to comment.