flvdec: Check the avio_seek return value after reading a metadata packet
[ffmpeg.git] / libavformat / flvdec.c
index 1b29740..81a71d3 100644 (file)
@@ -801,7 +801,13 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
                            type, size, flags);
 
 skip:
-            avio_seek(s->pb, next, SEEK_SET);
+            if (avio_seek(s->pb, next, SEEK_SET) != next) {
+                // This can happen if flv_read_metabody above read past
+                // next, on a non-seekable input, and the preceding data has
+                // been flushed out from the IO buffer.
+                av_log(s, AV_LOG_ERROR, "Unable to seek to the next packet\n");
+                return AVERROR_INVALIDDATA;
+            }
             continue;
         }