From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B2FC146813 for ; Mon, 19 Jun 2023 16:01:19 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D475568C026; Mon, 19 Jun 2023 19:01:15 +0300 (EEST) Received: from mail-m118206.qiye.163.com (mail-m118206.qiye.163.com [115.236.118.206]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9F7FB68BF4B for ; Mon, 19 Jun 2023 19:01:09 +0300 (EEST) Received: from [192.168.20.218] (unknown [120.230.119.239]) by mail-m118206.qiye.163.com (HMail) with ESMTPA id D25C7BE0FDD for ; Tue, 20 Jun 2023 00:01:02 +0800 (CST) Message-ID: <30247c6c-5fe6-8131-d4e9-b6388846437d@sweelia.com> Date: Tue, 20 Jun 2023 00:00:57 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 From: Armstrong Huang To: ffmpeg-devel@ffmpeg.org Content-Language: en-US X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFPN1dZLVlBSVdZDwkaFQgSH1lBWRpPSRlWSx9LGEofSktMGk9DVQIWExYaEhckFA4PWV dZGBILWUFZSklLVUlIS1VKSkJVSUhCWVdZFhoPEhUdFFlBWUtVS1VLVUtZBg++ X-HM-Tid: 0a88d46361b32d28kusnd25c7be0fdd X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PBw6TQw*MzlKShw2AU0iQi0o PUswCRdVSlVKTUNMSkJLT01ITkpJVTMWGhIXVRoJFggPCRQVHDsIDB4eFxIaVRgUFkVZV1kSC1lB WUpJS1VJSEtVSkpCVUlIQllXWQgBWUFJSUJCNwY+ Subject: [FFmpeg-devel] [PATCH] flvdec: Check the avio_seek return value after reading a metadata packet X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: In most cases, flv_read_metabody reads pass the beginning of the meta_pos. if the beginning of the meta_pos had been flushed from the IO buffer, we would not be able to seek to the right position (for a nonseekable stream). Is better to check the seek result and skip the current flv body if necessary, than to silently try to read from a desynchronized stream that will only be interpreted as garbage. Signed-off-by: Armstrong Huang --- libavformat/flvdec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index d83edff727..9d2b0730f1 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -1096,7 +1096,14 @@ retry: } else if (type == TYPE_UNKNOWN) { stream_type = FLV_STREAM_TYPE_DATA; } - avio_seek(s->pb, meta_pos, SEEK_SET); + if (avio_seek(s->pb, meta_pos, SEEK_SET) != meta_pos) { + // This can happen after flv_read_metabody + // above, 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 back to the flv tag body\n"); + goto skip; + } } } else { av_log(s, AV_LOG_DEBUG, -- 2.20.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".