plugins/id3: Fix id3v2 header size calculation
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 28 Aug 2013 04:24:35 +0000 (01:24 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 28 Aug 2013 21:48:35 +0000 (18:48 -0300)
commit95930b0a52cd21748055bc943965e0554cee6c8a
tree237addead2edff72c982fa58b6e380f490920870
parent84c12e7186a69addfc779bb0d079aeefa28d5d48
plugins/id3: Fix id3v2 header size calculation

_parse_id3v2() was not getting the size of the frame correctly. Since
the number uses at most 7 bits, we can't use _to_uint() function. For
example, 0x00000201 should be translated as 257, not 513.

We were also relying on _parse_id3v2() letting the fd in the right
position to look for the sync byte. However if this function read too
little and ave up parsing we were left in the middle of some ID3 frame.
Also, if there are other mistakes in the tag, we could end up reading
too much and losing the first sync byte.

Be safe and skip the amount of bytes as written into the ID3 header (or
skip just the ID3 tag if _parse_id3v2() fails badly).

We also skip the extended header if it exists and rename the
syncframe_offset to sync_offset everywhere.

Reference: Section 3.1 of ID3v2 tag specification
(http://id3.org/id3v2.3.0)
src/plugins/id3/id3.c