avformat/oggparseogm: Check lb against psize
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 9 Mar 2018 00:05:20 +0000 (01:05 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 10 Mar 2018 01:44:45 +0000 (02:44 +0100)
No testcase, this was found during code review

Found-by: Matt Wolenetz <wolenetz@google.com>
Reviewed-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/oggparseogm.c

index 4b4edf2..a074537 100644 (file)
@@ -176,6 +176,9 @@ ogm_packet(AVFormatContext *s, int idx)
         os->pflags |= AV_PKT_FLAG_KEY;
 
     lb = ((*p & 2) << 1) | ((*p >> 6) & 3);
+    if (os->psize < lb + 1)
+        return AVERROR_INVALIDDATA;
+
     os->pstart += lb + 1;
     os->psize -= lb + 1;