[FFmpeg-devel] [PATCH] avformat/id3v2: support buggy id3v2.3 tag length in id3v2.4

Michael Niedermayer michaelni at gmx.at
Thu Oct 16 17:10:38 CEST 2014


On Thu, Oct 16, 2014 at 11:44:47AM +0200, Benoit Fouet wrote:
> Some encoders do not use syncsafe sizes in v2.4 id3 tags. Check the next
> tag to try to choose between the two.
> 
> Fixes ticket #4003
> ---
>  libavformat/id3v2.c | 42 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 5469e0a..3bccd76 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -170,6 +170,23 @@ static unsigned int get_size(AVIOContext *s, int len)
>      return v;
>  }
>  
> +/* No real verification, only check that the tag consists of
> + * a combination of capital alpha-numerical characters */
> +static int is_tag(const char *buf, int len)
> +{
> +    if (!len)
> +        return 0;
> +
> +    while (len--)
> +        if ((buf[len] < 'A' ||
> +             buf[len] > 'Z') &&
> +            (buf[len] < '0' ||
> +             buf[len] > '9'))
> +            return 0;
> +
> +    return 1;
> +}
> +
>  /**
>   * Free GEOB type extra metadata.
>   */
> @@ -734,8 +751,31 @@ static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata,
>              tag[4] = 0;
>              if (version == 3) {
>                  tlen = avio_rb32(pb);
> -            } else
> +            } else {
>                  tlen = get_size(pb, 4);
> +                if (tlen > 0x7f) {

i think that check isnt sufficient to detect that the 2 readings
differ. For example 0xFF would be read as 0xFF by one and 0x7F by
the other and would not trigger this

also maybe len could be used to distingish a subset of cases

and there is the problem with seekable=0 streams where seeking
back might fail, not sure what to do in that case ...


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141016/3729ecdc/attachment.asc>


More information about the ffmpeg-devel mailing list