[FFmpeg-cvslog] flvdec: Check the avio_seek return value after reading a metadata packet

Martin Storsjö git at videolan.org
Fri Oct 27 03:30:22 EEST 2017


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Fri Oct 27 08:27:43 2017 +0800| [15537c904ec96e4d2e9435100d403283a5fed029] | committer: Steven Liu

flvdec: Check the avio_seek return value after reading a  metadata packet

merge from libav: 585dc1aecef0371ad6f16cb3750ae2a6da9cf00a

If the metadata packet is corrupted, flv_read_metabody can accidentally
read past the start of the next packet. If the start of the  next packet
had been flushed out of the IO buffer, we would be unable to seek to
the right position (on a nonseekable stream).

Prefer to clearly error out instead of silently  trying to read from a
desynced stream which will only be interpreted as garbage.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=15537c904ec96e4d2e9435100d403283a5fed029
---

 libavformat/flvdec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 2e70352c53..2d89bef15f 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1015,7 +1015,13 @@ retry:
                    "Skipping flv packet: type %d, size %d, flags %d.\n",
                    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;
+            }
             ret = FFERROR_REDO;
             goto leave;
         }



More information about the ffmpeg-cvslog mailing list