Commit ef7fe81b authored by Steven Liu's avatar Steven Liu

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

merge from libav: 585dc1ae

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.
Signed-off-by: 's avatarSteven Liu <lq@chinaffmpeg.org>
parent 25b50964
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment