summaryrefslogtreecommitdiffstats
path: root/wp-includes/ID3/module.audio.mp3.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:30 +0000
commitfa9a33d818470a5796f0ff8797f98b510ed8de18 (patch)
treebde6a1eede376f9b5df5898ce812330152984d8e /wp-includes/ID3/module.audio.mp3.php
parentReleasing progress-linux version 6.4.3+dfsg1-1~progress7.99u1. (diff)
downloadwordpress-fa9a33d818470a5796f0ff8797f98b510ed8de18.tar.xz
wordpress-fa9a33d818470a5796f0ff8797f98b510ed8de18.zip
Merging upstream version 6.5+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/ID3/module.audio.mp3.php')
-rw-r--r--wp-includes/ID3/module.audio.mp3.php26
1 files changed, 8 insertions, 18 deletions
diff --git a/wp-includes/ID3/module.audio.mp3.php b/wp-includes/ID3/module.audio.mp3.php
index 3d8a944..0d8fee3 100644
--- a/wp-includes/ID3/module.audio.mp3.php
+++ b/wp-includes/ID3/module.audio.mp3.php
@@ -1380,11 +1380,11 @@ class getid3_mp3 extends getid3_handler
$Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])] = isset($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]) ? ++$Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])] : 1;
$Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]] = isset($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]) ? ++$Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]] : 1;
if (++$frames_scanned >= $max_frames_scan) {
- $pct_data_scanned = ($this->ftell() - $info['avdataoffset']) / ($info['avdataend'] - $info['avdataoffset']);
+ $pct_data_scanned = getid3_lib::SafeDiv($this->ftell() - $info['avdataoffset'], $info['avdataend'] - $info['avdataoffset']);
$this->warning('too many MPEG audio frames to scan, only scanned first '.$max_frames_scan.' frames ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.');
foreach ($Distribution as $key1 => $value1) {
foreach ($value1 as $key2 => $value2) {
- $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned);
+ $Distribution[$key1][$key2] = $pct_data_scanned ? round($value2 / $pct_data_scanned) : 1;
}
}
break;
@@ -1475,7 +1475,7 @@ class getid3_mp3 extends getid3_handler
$SyncSeekAttemptsMax = 1000;
$FirstFrameThisfileInfo = null;
while ($SynchSeekOffset < $sync_seek_buffer_size) {
- if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && !feof($this->getid3->fp)) {
+ if ((($avdataoffset + $SynchSeekOffset) < $info['avdataend']) && !$this->feof()) {
if ($SynchSeekOffset > $sync_seek_buffer_size) {
// if a synch's not found within the first 128k bytes, then give up
@@ -1490,20 +1490,6 @@ class getid3_mp3 extends getid3_handler
unset($info['mpeg']);
}
return false;
-
- } elseif (feof($this->getid3->fp)) {
-
- $this->error('Could not find valid MPEG audio synch before end of file');
- if (isset($info['audio']['bitrate'])) {
- unset($info['audio']['bitrate']);
- }
- if (isset($info['mpeg']['audio'])) {
- unset($info['mpeg']['audio']);
- }
- if (isset($info['mpeg']) && (!is_array($info['mpeg']) || (count($info['mpeg']) == 0))) {
- unset($info['mpeg']);
- }
- return false;
}
}
@@ -1652,7 +1638,7 @@ class getid3_mp3 extends getid3_handler
}
$frames_scanned++;
if ($frames_scan_per_segment && (++$frames_scanned_this_segment >= $frames_scan_per_segment)) {
- $this_pct_scanned = ($this->ftell() - $scan_start_offset[$current_segment]) / ($info['avdataend'] - $info['avdataoffset']);
+ $this_pct_scanned = getid3_lib::SafeDiv($this->ftell() - $scan_start_offset[$current_segment], $info['avdataend'] - $info['avdataoffset']);
if (($current_segment == 0) && (($this_pct_scanned * $max_scan_segments) >= 1)) {
// file likely contains < $max_frames_scan, just scan as one segment
$max_scan_segments = 1;
@@ -1743,6 +1729,10 @@ class getid3_mp3 extends getid3_handler
}
$info['audio']['channels'] = $info['mpeg']['audio']['channels'];
+ if ($info['audio']['channels'] < 1) {
+ $this->error('Corrupt MP3 file: no channels');
+ return false;
+ }
$info['audio']['channelmode'] = $info['mpeg']['audio']['channelmode'];
$info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
return true;