[FFmpeg-devel] [PATCH] rmdec.c: correctly skip indexes

Reimar Döffinger Reimar.Doeffinger
Mon Mar 9 23:14:22 CET 2009


On Mon, Mar 09, 2009 at 05:50:10PM -0400, Ronald S. Bultje wrote:
> Index: ffmpeg-svn/libavformat/rmdec.c
> ===================================================================
> --- ffmpeg-svn.orig/libavformat/rmdec.c	2009-03-09 09:45:42.000000000 -0400
> +++ ffmpeg-svn/libavformat/rmdec.c	2009-03-09 17:48:36.000000000 -0400
> @@ -440,7 +440,18 @@
>              state= (state<<8) + get_byte(pb);
>  
>              if(state == MKBETAG('I', 'N', 'D', 'X')){
> -                len = get_be16(pb) - 6;
> +                int n_pkts;
> +                len = get_be32(pb);
> +                url_fskip(pb, 2);
> +                n_pkts = get_be32(pb);
> +                if (len == 20)
> +                    /* some files don't add index entries to chunk size... */
> +                    len += n_pkts * 14;
> +                else if (len - 20 != n_pkts * 14)
> +                        av_log(s, AV_LOG_WARNING,
> +                               "Index size %d (%d pkts) looks broken.\n",
> +                               len, n_pkts);

The indendation is off. Also I think moving the 20 to the other side
obfuscates things. Consider of maybe this is better:

int fixed_len;
len = get_be32(pb);
url_fskip(pb, 2);
// 20 bytes header + 14 bytes per index entry
fixed_len = 20 + 14 * get_be32(pb);
if (len == 20) len = fixed_len; // some files ...
else if (len != fixed_len) // trust len for now...
    av_log...
len -= 14; // we already read part of the index header




More information about the ffmpeg-devel mailing list