From patchwork Sat Jul 20 18:32:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 14006 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1E1F0449A54 for ; Sat, 20 Jul 2019 21:32:47 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F3CBA68A957; Sat, 20 Jul 2019 21:32:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx1.mailbox.org (mx1.mailbox.org [80.241.60.212]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0F4E468A92E for ; Sat, 20 Jul 2019 21:32:40 +0300 (EEST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 9E2D34C623 for ; Sat, 20 Jul 2019 20:32:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id Htl0k24C2tg9 for ; Sat, 20 Jul 2019 20:32:35 +0200 (CEST) To: FFmpeg development discussions and patches From: Gyan Message-ID: Date: Sun, 21 Jul 2019 00:02:31 +0530 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] avformat/mov: fix return code for trun box with no sample entries 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Affected files can now be demuxed. Verified with John Stebbins. FATE passes. Gyan From 48175cd745f8abd0546487907c4596550e3c73bf Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Sat, 20 Jul 2019 23:44:14 +0530 Subject: [PATCH] avformat/mov: fix return code for trun box with no sample entries A value of zero for sample_count in trun box is not prohibited by 14496-12 section 8.8.8. 4a9d32baca disallowed this which led the demuxer to error out when reading the header of valid files. --- libavformat/mov.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 327a25bbdf..ea26d78d91 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4776,13 +4776,14 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) distance = 0; av_log(c->fc, AV_LOG_TRACE, "first sample flags 0x%x\n", first_sample_flags); + if (entries == 0) + return 0; + // realloc space for new index entries if((uint64_t)st->nb_index_entries + entries >= UINT_MAX / sizeof(AVIndexEntry)) { entries = UINT_MAX / sizeof(AVIndexEntry) - st->nb_index_entries; av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n"); } - if (entries <= 0) - return -1; requested_size = (st->nb_index_entries + entries) * sizeof(AVIndexEntry); new_entries = av_fast_realloc(st->index_entries,