asfdec: fix assert failure on invalid files
authorUoti Urpala <uoti.urpala.pp1.inet.fi>
Sun, 24 Apr 2011 04:21:30 +0000 (07:21 +0300)
committerRonald S. Bultje <rsbultje@gmail.com>
Wed, 4 May 2011 02:36:08 +0000 (22:36 -0400)
Add an extra size validity check in asf_read_frame_header(). Without
this asf->packet_size_left may become negative, which triggers an
assertion failure later.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
libavformat/asfdec.c

index 637ceed..77c8449 100644 (file)
@@ -864,6 +864,10 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){
         }
         //printf("Fragsize %d\n", asf->packet_frag_size);
     } else {
+        if (rsize > asf->packet_size_left) {
+            av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n");
+            return -1;
+        }
         asf->packet_frag_size = asf->packet_size_left - rsize;
         //printf("Using rest  %d %d %d\n", asf->packet_frag_size, asf->packet_size_left, rsize);
     }