[Slim-Checkins] r10616 - in /trunk/server: Changelog6.html
lib/MP3/Info.pm
dsully at svn.slimdevices.com
dsully at svn.slimdevices.com
Tue Nov 7 17:08:25 PST 2006
Author: dsully
Date: Tue Nov 7 17:08:25 2006
New Revision: 10616
URL: http://svn.slimdevices.com?rev=3D10616&view=3Drev
Log:
Bug: 4486
Description: Don't read past the end of the file. Causes Win32 to freak out.
Optimize read()s to only call once when looking for an ID3v2 header.
Modified:
trunk/server/Changelog6.html
trunk/server/lib/MP3/Info.pm
Modified: trunk/server/Changelog6.html
URL: http://svn.slimdevices.com/trunk/server/Changelog6.html?rev=3D10616&r1=
=3D10615&r2=3D10616&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/server/Changelog6.html (original)
+++ trunk/server/Changelog6.html Tue Nov 7 17:08:25 2006
@@ -116,6 +116,7 @@
<li><a href=3D"http://bugs.slimdevices.com/show_bug.cgi?id=3D4457">#4457=
</a> - Nokia770 song info page doesn't delimit multiple artists with a comm=
a</li>
<li><a href=3D"http://bugs.slimdevices.com/show_bug.cgi?id=3D4464">#4464=
</a> - musicmagic crash using mixerlink</li>
<li><a href=3D"http://bugs.slimdevices.com/show_bug.cgi?id=3D4467">#4467=
</a> - Add for remote radio streams displays "Connecting" for lon=
g time</li>
+ <li><a href=3D"http://bugs.slimdevices.com/show_bug.cgi?id=3D4486">#4486=
</a> - Scanner.exe crash (reproducible)</li>
</ul>
</ul>
=
Modified: trunk/server/lib/MP3/Info.pm
URL: http://svn.slimdevices.com/trunk/server/lib/MP3/Info.pm?rev=3D10616&r1=
=3D10615&r2=3D10616&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/server/lib/MP3/Info.pm (original)
+++ trunk/server/lib/MP3/Info.pm Tue Nov 7 17:08:25 2006
@@ -1809,35 +1809,43 @@
# in the MP3 (eg for 'update' frames).
sub _get_v2head {
my $fh =3D $_[0] or return;
- my($v2h, $bytes, @bytes);
- $v2h->{offset} =3D $_[1] || 0;
+
+ my $v2h =3D {
+ 'offset' =3D> $_[1] || 0,
+ 'tag_size' =3D> 0,
+ };
=
# check first three bytes for 'ID3'
- seek $fh, $v2h->{offset}, SEEK_SET;
- read $fh, $bytes, 3;
+ seek($fh, $v2h->{offset}, SEEK_SET);
+ read($fh, my $header, 10);
+
+ my $tag =3D substr($header, 0, 3);
=
# (Note: Footers are dealt with in v2foot)
if ($v2h->{offset} =3D=3D 0) {
=
# JRF: Only check for special headers if we're at the start of the file.
- if ($bytes eq 'RIF' || $bytes eq 'FOR') {
- _find_id3_chunk($fh, $bytes) or return;
+ if ($tag eq 'RIF' || $tag eq 'FOR') {
+ _find_id3_chunk($fh, $tag) or return;
$v2h->{offset} =3D tell $fh;
- read $fh, $bytes, 3;
- }
- }
-
- return unless $bytes eq 'ID3';
+
+ read($fh, $header, 10);
+ $tag =3D substr($header, 0, 3);
+ }
+ }
+
+ return if $tag ne 'ID3';
=
# get version
- read $fh, $bytes, 2;
- $v2h->{version} =3D sprintf "ID3v2.%d.%d",
- @$v2h{qw[major_version minor_version]} =3D
- unpack 'c2', $bytes;
+ my ($major, $minor, $flags) =3D unpack ("x3CCC", $header);
+
+ $v2h->{version} =3D sprintf("ID3v2.%d.%d", $major, $minor);
+ $v2h->{major_version} =3D $major;
+ $v2h->{minor_version} =3D $minor;
=
# get flags
- read $fh, $bytes, 1;
- my @bits =3D split //, unpack 'b8', $bytes;
+ my @bits =3D split(//, unpack('b8', pack('v', $flags)));
+
if ($v2h->{major_version} =3D=3D 2) {
$v2h->{unsync} =3D $bits[7];
$v2h->{compression} =3D $bits[6]; # Should be ignored - no defined form
@@ -1851,14 +1859,15 @@
}
=
# get ID3v2 tag length from bytes 7-10
- $v2h->{tag_size} =3D 10; # include ID3v2 header size
+ my $rawsize =3D substr($header, 6, 4);
+
+ for my $b (unpack('C4', $rawsize)) {
+
+ $v2h->{tag_size} =3D ($v2h->{tag_size} << 7) + $b;
+ }
+
+ $v2h->{tag_size} +=3D 10; # include ID3v2 header size
$v2h->{tag_size} +=3D 10 if $v2h->{footer};
- read $fh, $bytes, 4;
- @bytes =3D reverse unpack 'C4', $bytes;
- foreach my $i (0 .. 3) {
- # whoaaaaaa nellllllyyyyyy!
- $v2h->{tag_size} +=3D $bytes[$i] * 128 ** $i;
- }
=
# JRF: I think this is done wrongly - this should be part of the main fra=
me,
# and therefore under ID3v2.3 it's subject to unsynchronisation
@@ -1867,14 +1876,25 @@
=
# get extended header size (2.3/2.4 only)
$v2h->{ext_header_size} =3D 0;
+
if ($v2h->{ext_header}) {
- read $fh, $bytes, 4;
- @bytes =3D reverse unpack 'C4', $bytes;
+ my $filesize =3D -s $fh;
+
+ read $fh, my $bytes, 4;
+ my @bytes =3D reverse unpack 'C4', $bytes;
=
# use syncsafe bytes if using version 2.4
my $bytesize =3D ($v2h->{major_version} > 3) ? 128 : 256;
for my $i (0..3) {
$v2h->{ext_header_size} +=3D $bytes[$i] * $bytesize ** $i;
+ }
+
+ # Bug 4486
+ # Don't try to read past the end of the file if we have a
+ # bogus extended header size.
+ if (($v2h->{ext_header_size} - 10 ) > -s $fh) {
+
+ return $v2h;
}
=
# Read the extended header
More information about the checkins
mailing list