nutdec: check maxpos in read_sm_data before returning success
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Sat, 27 Jun 2015 15:50:56 +0000 (17:50 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 22 Jul 2015 23:35:09 +0000 (01:35 +0200)
Otherwise sm_size can be larger than size, which results in a negative
packet size.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
(cherry picked from commit 6b9fdf7f4f07926557048070cc2af3cfd0e3fe50)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
(cherry picked from commit eddf146ada12b394a7796af12bff2121505dc4a1)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/nutdec.c

index 056d6fb..056f1f2 100644 (file)
@@ -950,6 +950,9 @@ static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int
         AV_WL32(dst+4, skip_end);
     }
 
+    if (avio_tell(bc) >= maxpos)
+        return AVERROR_INVALIDDATA;
+
     return 0;
 }