From d0e347f9d501d184436b1c3dc35d0e7dbfada614 Mon Sep 17 00:00:00 2001 From: James Heinrich Date: Mon, 20 May 2024 13:28:56 -0400 Subject: [PATCH] #444 ID3v2 Uninitialized string offset 0 https://github.com/JamesHeinrich/getID3/issues/444 --- getid3/getid3.php | 2 +- getid3/module.tag.id3v2.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/getid3/getid3.php b/getid3/getid3.php index cc764baf..c3cbb8be 100644 --- a/getid3/getid3.php +++ b/getid3/getid3.php @@ -387,7 +387,7 @@ class getID3 */ protected $startup_warning = ''; - const VERSION = '1.9.23-202404261550'; + const VERSION = '1.9.23-202405201327'; const FREAD_BUFFER_SIZE = 32768; const ATTACHMENTS_NONE = false; diff --git a/getid3/module.tag.id3v2.php b/getid3/module.tag.id3v2.php index 4ee9b27e..9e091d99 100644 --- a/getid3/module.tag.id3v2.php +++ b/getid3/module.tag.id3v2.php @@ -1068,13 +1068,15 @@ public function ParseID3v2Frame(&$parsedFrame) { $parsedFrame['lyrics'][$timestampindex]['data'] = substr($frame_remainingdata, $frame_offset, $frame_terminatorpos - $frame_offset); $frame_remainingdata = substr($frame_remainingdata, $frame_terminatorpos + strlen($frame_textencoding_terminator)); - if (($timestampindex == 0) && (ord($frame_remainingdata[0]) != 0)) { - // timestamp probably omitted for first data item - } else { - $parsedFrame['lyrics'][$timestampindex]['timestamp'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, 0, 4)); - $frame_remainingdata = substr($frame_remainingdata, 4); + if (strlen($frame_remainingdata)) { // https://github.com/JamesHeinrich/getID3/issues/444 + if (($timestampindex == 0) && (ord($frame_remainingdata[0]) != 0)) { + // timestamp probably omitted for first data item + } else { + $parsedFrame['lyrics'][$timestampindex]['timestamp'] = getid3_lib::BigEndian2Int(substr($frame_remainingdata, 0, 4)); + $frame_remainingdata = substr($frame_remainingdata, 4); + } + $timestampindex++; } - $timestampindex++; } } unset($parsedFrame['data']);