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

Ronald S. Bultje rsbultje
Mon Mar 9 22:50:10 CET 2009


Hi,

On Mon, Mar 9, 2009 at 4:40 PM, Reimar D?ffinger
<Reimar.Doeffinger at gmx.de> wrote:
> On Mon, Mar 09, 2009 at 12:39:16PM -0400, Ronald S. Bultje wrote:
>> - ? ? ? ? ? ? ? ?len = get_be16(pb) - 6;
>> + ? ? ? ? ? ? ? ?int size, n_pkts;
>> + ? ? ? ? ? ? ? ?size = get_be32(pb);
>> + ? ? ? ? ? ? ? ?url_fskip(pb, 2);
>> + ? ? ? ? ? ? ? ?n_pkts = get_be32(pb);
>> + ? ? ? ? ? ? ? ?if (size == 0x14) {
>> + ? ? ? ? ? ? ? ? ? ?/* some files don't add index entries to total size... */
>> + ? ? ? ? ? ? ? ? ? ?len = size - 14 + n_pkts * 14;
>> + ? ? ? ? ? ? ? ?} else {
>> + ? ? ? ? ? ? ? ? ? ?len = size - 14;
>> + ? ? ? ? ? ? ? ? ? ?if (size - 0x14 != n_pkts * 14)
>> + ? ? ? ? ? ? ? ? ? ? ? ?av_log(s, AV_LOG_WARNING,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "Index size %d (%d pkts) looks broken.\n",
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size, n_pkts);
>> + ? ? ? ? ? ? ? ?}
>
> Why not reusing the len variable? Also the -14 is common etc.

As suggested, new patch attached.

Ronald
-------------- next part --------------
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);
+                len -= 14; // we already read part of the index header
                 if(len<0)
                     continue;
                 goto skip;



More information about the ffmpeg-devel mailing list