plugins/id3: Fix id3v2 not skipping CRC if present
authorLucas De Marchi <lucas.demarchi@intel.com>
Wed, 28 Aug 2013 21:45:55 +0000 (18:45 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 28 Aug 2013 21:50:56 +0000 (18:50 -0300)
If there's a CRC field after the extended header, we need to skip it,
too. The worst thing that could happen here is the CRC containing a sync
byte and having no other frames in the ID3v2. In this case our parser
would not find correct mp3 information.

src/plugins/id3/id3.c

index a5c9c22..8e3a56b 100644 (file)
@@ -756,16 +756,18 @@ _parse_id3v2(int fd, long id3v2_offset, struct id3_info *info,
     if (extended_header) {
         /* skip extended header */
         unsigned int extended_header_size;
-        char extended_header_data[4];
+        char extended_header_data[6];
+        bool crc;
 
         if (read(fd, extended_header_data, 4) != 4)
             return -1;
 
         extended_header_size = _to_uint(extended_header_data, 4);
-        lseek(fd, extended_header_size - 4, SEEK_CUR);
+        crc = extended_header_data[5] & 0x8000;
 
-        *ptag_size += extended_header_size;
+        *ptag_size += extended_header_size + (crc * 4);
 
+        lseek(fd, extended_header_size - 6, SEEK_CUR);
         frame_data_pos += extended_header_size;
         frame_data_length -= extended_header_size;
     }