From patchwork Sat Mar 25 13:15:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 3095 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp505335vsy; Sat, 25 Mar 2017 06:16:47 -0700 (PDT) X-Received: by 10.28.158.148 with SMTP id h142mr2040413wme.36.1490447807007; Sat, 25 Mar 2017 06:16:47 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l44si7414448wrl.51.2017.03.25.06.16.46; Sat, 25 Mar 2017 06:16:46 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 549396898DC; Sat, 25 Mar 2017 15:16:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg327.qq.com (unknown [14.17.43.158]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E08F26891E1 for ; Sat, 25 Mar 2017 15:16:14 +0200 (EET) X-QQ-mid: bizesmtp5t1490447748t2yqx9fwd Received: from localhost (unknown [123.120.39.246]) by esmtp4.qq.com (ESMTP) with id ; Sat, 25 Mar 2017 21:15:38 +0800 (CST) X-QQ-SSF: 01100000002000F0FF30000A0000000 X-QQ-FEAT: 5t7Y1p3pIzGyyYau5LRCsclYrH18ZSbMppACFT7M5WSOtCyXU/N0kD75jKtJ7 TyFul9c/K9dvm8s2/gGmGm7Sp5wwZDOasQgWrzqeVeBA0rPZAV6FWbuGUD92nXhsjUuqX2a zsxxFL0otlH6VLlF+ta78hCowck98KiGkCUuUDQswb4nZPzBCOau+9NlF5fKOGznSbYdRmP EmECOAkTpaT3Z9grkchph+xhpyJUpuv8X9zR5NvjajwkyjaEzvonhlBifIR62poUiuRI4Jj PKc4b4MiITAcs1SO2PVjKoOSk= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 Mar 2017 21:15:28 +0800 Message-Id: <20170325131528.62595-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: References: X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH v2] avformat/flvdec: check FLVHeader PreviousTagSize0 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" refer to SPEC: Annex E. The FLV File Format said: E.3 TheFLVFileBody have a table: Field Type Comment PreviousTagSize0 UI32 Always 0 Signed-off-by: Steven Liu --- libavformat/flvdec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index cdcfb9c..94c9e28 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -709,6 +709,7 @@ static int flv_read_header(AVFormatContext *s) int flags; FLVContext *flv = s->priv_data; int offset; + int pre_tag_size = 0; avio_skip(s->pb, 4); flags = avio_r8(s->pb); @@ -719,7 +720,16 @@ static int flv_read_header(AVFormatContext *s) offset = avio_rb32(s->pb); avio_seek(s->pb, offset, SEEK_SET); - avio_skip(s->pb, 4); + + /* Annex E. The FLV File Format + * E.3 TheFLVFileBody + * Field Type Comment + * PreviousTagSize0 UI32 Always 0 + * */ + pre_tag_size = avio_rb32(s->pb); + if (pre_tag_size) { + av_log(s, AV_LOG_WARNING, "Read FLV header error, input file is not a standard flv format, first PreviousTagSize0 always is 0\n"); + } s->start_time = 0; flv->sum_flv_tag_size = 0;