From patchwork Sun Dec 11 11:54:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 39675 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2856242pzb; Sun, 11 Dec 2022 03:55:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6HeG6uToWrzy5gScUxvt42u8Sw3hNg9brKfUwHByjx9w/ORsnrPPArRVKF7tEYGLvOgkIJ X-Received: by 2002:a17:907:7b88:b0:7c0:c1cc:c68 with SMTP id ne8-20020a1709077b8800b007c0c1cc0c68mr14554211ejc.6.1670759734327; Sun, 11 Dec 2022 03:55:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670759734; cv=none; d=google.com; s=arc-20160816; b=PHOG93iL8UUw1/UCTl4te/CsQqu3DQ4Odwk0S7T8SB6qJO6bxGn1tuzEEGg8LyBTvm 1/jLbNldb5Bai9V1V1D8PwCJ9dABEdMTwMHBcBxrBTBgQU6la61RrblQezpbsW0oht9F 6lMZaJnuPY7DW/zQ3z2EIfoNdkR9LGdeC2O8Ko9n6siaccaj2OLyBHyhYMbutUKPiAaz Yau15osoxcxxpoFjtJ0W3xqaOD9Mx4lHMcwviVUENOl7+mDf0MjHDZeuMAqAMM7rzV1x PJq8DCPjrVB2CbUXNW8ZVdLqO4S89QM+vR3IhL2MRUlqdKSjD3Zf6vWfh+h7YaupzCFg xyAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=X+MB9h/3erEIrXnvcSHav2VFSBqZqVhQWLaguYIgXBs=; b=pa0Aj5PSo+s2sjC33EvSDuG9G6hmahOiwlMuovcFlkNyDYJi+METJdlC81+jp9oONs hStExjHan2k6aEGhxS4KYAk56RbwVw4wDI6bt82Sj3COekcDC2HjEvecrIbEfBXzDO/e y6p32onegN+wq6mjUvbOfMXtIL60bvqJjSy31SX4KLID0YczpNARoXRQTAlJQso380ql +MfmhTT8oFBsB5YGi1rje3XN0IQyT9OEJMN2L793kftb+nRAP0TfaYXsbGv363+S8mIJ 4ryqPtLW+4VwlxCYe9Yc+WHngNv3d7Nlfe2jDupKQ+4rTohqw1qxvlsGi1aRQYyVlH/W resw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gb40-20020a170907962800b007c15ca85481si2439845ejc.812.2022.12.11.03.55.33; Sun, 11 Dec 2022 03:55:34 -0800 (PST) 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 3F98A68BDB2; Sun, 11 Dec 2022 13:55:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1642D68BCF7 for ; Sun, 11 Dec 2022 13:55:24 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8369DE815C; Sun, 11 Dec 2022 12:55:22 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H_4mUXrfabNl; Sun, 11 Dec 2022 12:55:20 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5FEB9E8034; Sun, 11 Dec 2022 12:55:19 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Dec 2022 12:54:40 +0100 Message-Id: <20221211115440.9942-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221204235002.26754-2-cus@passwd.hu> References: <20221204235002.26754-2-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] avformat/mov: re-allow zero sample sizes if that is not the default 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mhZ85N9RiWxq Patch 03d81a044ad587ea83567f75dc36bc3d64278199 disallowed zero sample sizes, but there are some files in the wild which have zero sized samples (e.g. no audio in some part of a live recording). Fix this by simply ignoring a trun box with zero sized samples. This approach fixes the original timeout issue from fuzzed files differently. Signed-off-by: Marton Balint --- libavformat/mov.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 935b2f8d9f..63e0b614df 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5121,6 +5121,11 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (flags & MOV_TRUN_DATA_OFFSET) data_offset = avio_rb32(pb); if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb); + if (entries && !frag->size && !(flags & MOV_TRUN_SAMPLE_SIZE)) { + av_log(c->fc, AV_LOG_WARNING, "Ignoring trun box with zero sized samples\n"); + entries = 0; + } + frag_stream_info = get_current_frag_stream_info(&c->frag_index); if (frag_stream_info) { if (frag_stream_info->next_trun_dts != AV_NOPTS_VALUE) { @@ -5293,8 +5298,6 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) distance++; if (av_sat_add64(dts, sample_duration) != dts + (uint64_t)sample_duration) return AVERROR_INVALIDDATA; - if (!sample_size) - return AVERROR_INVALIDDATA; dts += sample_duration; offset += sample_size; sc->data_size += sample_size;