Skip Menu |

This queue is for tickets about the MPEG-ID3v2Tag CPAN distribution.

Report information
The Basics
Id: 22271
Status: resolved
Priority: 0/
Queue: MPEG-ID3v2Tag

People
Owner: Nobody in particular
Requestors: revdiablo [...] wd39.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.36
Fixed in: 0.37



Subject: Incorrectly interpreting frame size
The 'parse' method in MPEG::ID3Frame incorrectly interprets the frame size that it extracted. In short, it needs to pass it through the handy 'MPEG::ID3v2Tag::UnMungeSize' function to convert it to the real number. This doesn't cause any negative effects unless the frame goes beyond a certain size. But when that happens, the rest of the tag is parsed improperly. I have included a (very simple) patch that fixes the problem.
Subject: ID3v2Tag.pm.diff
--- ID3v2Tag.pm.orig 2006-10-19 09:20:03.593750000 -0700 +++ ID3v2Tag.pm.mine 2006-10-19 09:30:49.578125000 -0700 @@ -580,6 +580,8 @@ my ($frameid, $size, $flags0, $flags1) = unpack("a4NCC", $header) ; $self->{FRAMEID} = $frameid ; + my $sane_size = MPEG::ID3v2Tag::UnMungeSize($size); + $self->flag_tag_alter(($flags0>>7) & 1) ; $self->flag_file_alter(($flags0>>6) & 1) ; $self->flag_read_only(($flags0>>5) & 1) ; @@ -588,7 +590,7 @@ $self->flag_encryption(($flags1>>6) & 1) ; $self->flag_grouping_identity(($flags1>>5) & 1) ; - $original_body = $body = substr($$dataref, 0, $size, "") ; + $original_body = $body = substr($$dataref, 0, $sane_size, "") ; if ($self->flag_encryption() || $self->flag_grouping_identity()) { # we don't know how to parse this field because we don't support
Slight modifications were necessary to the patch. The UnMungeSize should only be applied if it's an ID3v2.4 tag. Bug fixed and pending new release.
Index: lib/MPEG/ID3v2Tag.pm =================================================================== --- lib/MPEG/ID3v2Tag.pm (revision 1360) +++ lib/MPEG/ID3v2Tag.pm (working copy) @@ -340,7 +340,7 @@ # parse the frames while there is data to parse. while ($data ne '') { - my $frame = MPEG::ID3Frame->parse(\$data) ; + my $frame = MPEG::ID3Frame->parse(\$data, $tag) ; $tag->add_frame($frame) ; } @@ -570,7 +570,7 @@ #### sub parse { - my ($package, $dataref) = @_ ; + my ($package, $dataref, $tag) = @_ ; my $self = {FROM_PARSER => 1} ; my ($body, $original_body) ; my $tmp ; @@ -580,6 +580,10 @@ my ($frameid, $size, $flags0, $flags1) = unpack("a4NCC", $header) ; $self->{FRAMEID} = $frameid ; + if (defined $tag and $tag->{MAJORVER} == 4) { + $size = MPEG::ID3v2Tag::UnMungeSize($size); + } + $self->flag_tag_alter(($flags0>>7) & 1) ; $self->flag_file_alter(($flags0>>6) & 1) ; $self->flag_read_only(($flags0>>5) & 1) ;