From: Thibaut M. <tma...@us...> - 2003-12-08 22:10:25
|
Update of /cvsroot/xine/xine-lib/src/demuxers In directory sc8-pr-cvs1:/tmp/cvs-serv11558 Modified Files: id3.h id3.c Log Message: - Fix wrong tag header constants. - Add more v2.3 and v2.4 constants - Check invalid flags Index: id3.h =================================================================== RCS file: /cvsroot/xine/xine-lib/src/demuxers/id3.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- id3.h 7 Dec 2003 23:05:41 -0000 1.1 +++ id3.h 8 Dec 2003 22:10:20 -0000 1.2 @@ -38,23 +38,57 @@ #define ID3V23_TAG FOURCC_TAG('I', 'D', '3', 3) /* id3 v2.3 tags */ #define ID3V24_TAG FOURCC_TAG('I', 'D', '3', 4) /* id3 v2.4 tags */ -/* id2v2.2 */ -#define ID3V22_FRAME_HEADER_SIZE 6 -#define ID3V22_UNSYNCH_FLAG 0x8000 -#define ID3V22_COMPRESS_FLAG 0x4000 +/* + * ID3 v2.2 + */ +/* tag header */ +#define ID3V22_UNSYNCH_FLAG 0x80 +#define ID3V22_COMPRESS_FLAG 0x40 +#define ID3V22_ZERO_FLAG 0x3F -/* id2v2.3 */ -#define ID3V23_FRAME_HEADER_SIZE 10 -#define ID3V23_UNSYNCH_FLAG 0x8000 -#define ID3V23_EXTHEAD_FLAG 0x4000 -#define ID3V23_EXP_FLAG 0x2000 +/* frame header */ +#define ID3V22_FRAME_HEADER_SIZE 6 -/* id2v2.4 */ -#define ID3V24_FRAME_HEADER_SIZE 10 -#define ID3V24_UNSYNCH_FLAG 0x8000 -#define ID3V24_EXTHEAD_FLAG 0x4000 -#define ID3V24_EXP_FLAG 0x2000 -#define ID3V24_FOOTER_FLAG 0x1000 +/* + * ID3 v2.3 + */ +/* tag header */ +#define ID3V23_UNSYNCH_FLAG 0x80 +#define ID3V23_EXT_HEADER_FLAG 0x40 +#define ID3V23_EXPERIMENTAL_FLAG 0x20 +#define ID3V23_ZERO_FLAG 0x1F + +/* frame header */ +#define ID3V23_FRAME_HEADER_SIZE 10 +#define ID3V23_FRAME_TAG_PRESERV_FLAG 0x8000 +#define ID3V23_FRAME_FILE_PRESERV_FLAG 0x4000 +#define ID3V23_FRAME_READ_ONLY_FLAG 0x2000 +#define ID3V23_FRAME_COMPRESS_FLAG 0x0080 +#define ID3V23_FRAME_ENCRYPT_FLAG 0x0040 +#define ID3V23_FRAME_GROUP_ID_FLAG 0x0020 +#define ID3V23_FRAME_ZERO_FLAG 0x1F1F + +/* + * ID3 v2.4 + */ +/* tag header */ +#define ID3V24_UNSYNCH_FLAG 0x80 +#define ID3V24_EXT_HEADER_FLAG 0x40 +#define ID3V24_EXPERIMENTAL_FLAG 0x20 +#define ID3V24_FOOTER_FLAG 0x10 +#define ID3V24_ZERO_FLAG 0x0F + +/* frame header */ +#define ID3V24_FRAME_HEADER_SIZE 10 +#define ID3V24_FRAME_TAG_PRESERV_FLAG 0x4000 +#define ID3V24_FRAME_FILE_PRESERV_FLAG 0x2000 +#define ID3V24_FRAME_READ_ONLY_FLAG 0x1000 +#define ID3V24_FRAME_GROUP_ID_FLAG 0x0040 +#define ID3V24_FRAME_COMPRESS_FLAG 0x0008 +#define ID3V24_FRAME_ENCRYPT_FLAG 0x0004 +#define ID3V24_FRAME_UNSYNCH_FLAG 0x0002 +#define ID3V24_FRAME_DATA_LEN_FLAG 0x0001 +#define ID3V24_FRAME_ZERO_FLAG 0x8FB0 typedef struct { uint32_t id; Index: id3.c =================================================================== RCS file: /cvsroot/xine/xine-lib/src/demuxers/id3.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- id3.c 7 Dec 2003 23:17:07 -0000 1.3 +++ id3.c 8 Dec 2003 22:10:20 -0000 1.4 @@ -20,7 +20,15 @@ * ID3 tag parser * * Supported versions: v1, v2.2, v2.3 - * TODO: v2.4 + * TODO: + * v1: genre + * v1.1: track info + * v2.2: unicode + * unsynchronize ? + * v2.3: unicode + * unsynchronize ? + * unzip support ? + * v2.4: parsing * * ID3v2 specs: http://www.id3.org/ * @@ -173,37 +181,53 @@ if (id3v2_parse_header(input, mp3_frame_header, &tag_header)) { + if (tag_header.flags & ID3V22_ZERO_FLAG) { + /* invalid flags */ + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + "id3: invalid header flags\n"); + input->seek (input, tag_header.size - pos, SEEK_CUR); + return 0; + } if (tag_header.flags & ID3V22_COMPRESS_FLAG) { - /* compressed tag ? just skip it */ + /* compressed tag: not supported */ + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + "id3: compressed tags are not supported\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); - } else { - /* frame parsing */ - while ((pos + ID3V22_FRAME_HEADER_SIZE) <= tag_header.size) { - if (id3v22_parse_frame_header(input, &tag_frame_header)) { - pos += ID3V22_FRAME_HEADER_SIZE; - if (tag_frame_header.id && tag_frame_header.size) { - if ((pos + tag_frame_header.size) <= tag_header.size) { - if (!id3v22_interp_frame(input, stream, &tag_frame_header)) { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame content\n"); - } - } else { + return 0; + } + if (tag_header.flags & ID3V22_UNSYNCH_FLAG) { + /* unsynchronized tag: not supported */ + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + "id3: unsynchronized tags are not supported\n"); + input->seek (input, tag_header.size - pos, SEEK_CUR); + return 0; + } + /* frame parsing */ + while ((pos + ID3V22_FRAME_HEADER_SIZE) <= tag_header.size) { + if (id3v22_parse_frame_header(input, &tag_frame_header)) { + pos += ID3V22_FRAME_HEADER_SIZE; + if (tag_frame_header.id && tag_frame_header.size) { + if ((pos + tag_frame_header.size) <= tag_header.size) { + if (!id3v22_interp_frame(input, stream, &tag_frame_header)) { xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: invalid frame header\n"); - input->seek (input, tag_header.size - pos, SEEK_CUR); - return 1; + "id3: invalid frame content\n"); } - pos += tag_frame_header.size; } else { - /* end of frames, the rest is padding */ + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + "id3: invalid frame header\n"); input->seek (input, tag_header.size - pos, SEEK_CUR); return 1; } + pos += tag_frame_header.size; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "id3: id3v2_parse_frame_header problem\n"); - return 0; + /* end of frames, the rest is padding */ + input->seek (input, tag_header.size - pos, SEEK_CUR); + return 1; } + } else { + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + "id3: id3v2_parse_frame_header problem\n"); + return 0; } } return 1; @@ -340,13 +364,26 @@ if (id3v2_parse_header(input, mp3_frame_header, &tag_header)) { - if (tag_header.flags & ID3V23_EXTHEAD_FLAG) { + if (tag_header.flags & ID3V23_ZERO_FLAG) { + /* invalid flags */ + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + "id3: invalid header flags\n"); + input->seek (input, tag_header.size - pos, SEEK_CUR); + return 0; + } + if (tag_header.flags & ID3V23_UNSYNCH_FLAG) { + /* unsynchronized tag: not supported */ + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + "id3: unsynchronized tags are not supported\n"); + input->seek (input, tag_header.size - pos, SEEK_CUR); + return 0; + } + if (tag_header.flags & ID3V23_EXT_HEADER_FLAG) { /* extended header */ if (!id3v23_parse_frame_ext_header(input, &tag_frame_ext_header)) { return 0; } } - /* frame parsing */ while ((pos + ID3V23_FRAME_HEADER_SIZE) <= tag_header.size) { if (id3v23_parse_frame_header(input, &tag_frame_header)) { @@ -377,7 +414,7 @@ } return 1; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3v22: id3v2_parse_header problem\n"); + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "id3v23: id3v2_parse_header problem\n"); return 0; } } |