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 A7D8546852 for ; Tue, 20 Jun 2023 15:06:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 771AA68C07A; Tue, 20 Jun 2023 18:06:12 +0300 (EEST) Received: from mail-m118207.qiye.163.com (mail-m118207.qiye.163.com [115.236.118.207]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EECFC68BDDE for ; Tue, 20 Jun 2023 18:06:04 +0300 (EEST) Received: from localhost.localdomain (unknown [120.230.119.239]) by mail-m118207.qiye.163.com (HMail) with ESMTPA id E1EFB90072F for ; Tue, 20 Jun 2023 23:05:59 +0800 (CST) From: Armstrong Huang To: ffmpeg-devel@ffmpeg.org Date: Tue, 20 Jun 2023 15:05:19 +0000 Message-Id: <20230620150519.15768-1-armstrong@sweelia.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <30247c6c-5fe6-8131-d4e9-b6388846437d@sweelia.com> References: <30247c6c-5fe6-8131-d4e9-b6388846437d@sweelia.com> X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFPN1dZLVlBSVdZDwkaFQgSH1lBWRofT0lWTkNKQ0hMTU9JHx9KVQIWExYaEhckFA4PWV dZGBILWUFZSklLVUlIS1VKSkJVSUhCWVdZFhoPEhUdFFlBWUtVS1VLVUtZBg++ X-HM-Tid: 0a88d957579f2d29kusne1efb90072f X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Phg6ORw5ITlLCRwXPQsBTxQM FhMaFA1VSlVKTUNMSUxITk1LTU5KVTMWGhIXVRoJFggPCRQVHDsIDB4eFxIaVRgUFkVZV1kSC1lB WUpJS1VJSEtVSkpCVUlIQllXWQgBWUFJSEpINwY+ 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 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index d83edff727..21ff73a1aa 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -1096,7 +1096,18 @@ 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 meta_pos: %ld\n", + meta_pos); + 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".