From patchwork Wed Dec 22 11:30:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 32834 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp6291713iog; Wed, 22 Dec 2021 03:31:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQD3c46LzSiQnxLs8N9yrBwgUPUQW4xe9jnuwZorhPyPoT3DsXSB/B0YwQgdQyz4XoKcQk X-Received: by 2002:aa7:ce0c:: with SMTP id d12mr2503395edv.88.1640172682963; Wed, 22 Dec 2021 03:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640172682; cv=none; d=google.com; s=arc-20160816; b=n2UE7DOMPcgJR6upFxP5/3wqOP2EU97b/Gn1ht8DUfJEw6+66r2qN7xwehumSMvsWM KiYzt41X+nhNnzeWKfrEHTOxjK1c1y55NLPHCzHe1qdxlOCOIVxMJemdJsjR5KjKhdHS 4Rg6hQOcKXvEONSJ/FyRIX9NkZiRIn1enyHHorJDC3rqttNg/RjvDyTZozmLYYhEzdb8 Rst6VzEXqOkmxUfj5PhvFtS1X5olpeD0l56Vw8Vf6X9OJcHDIDhZl3lhtMLfi8rlCouZ FvxE/AV6/kX/RTuaOUic02Fpidce23h0FdruyXlShCaiHyxHVLbzVPTCEJPodyrjmal0 60Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=ieKe2b9GffhGfrC3WDO4kI+ysmCFbSopKLYyiOX7SIo=; b=oS8yrLja/OvIAPcTl6VjqIs9mnB/pWVjC+m7XlHgMLyukUCoKFbjSYxl7RKXvQVVC4 UqDVWZOJuJzAux+iYbpqssPhMoD0T8b526aebK23XPZo1iTk/O58fN2oJWXood73SSA2 ggKOK4LtQaB5KXxISYhlsUowWbi8NN+EK4/N+AGql2hTpqtMU871wAV4kwg75vQRA6cp WIerZD9Fb3kYJ20SreOd0Yo1q8ohiVR9PxFIAQ2s3EgLEkvpslAYo5ylemjabTKI2wg6 WS71xZ2E+/hWnRSeiIl8d7n+58fap/WNDZtsSb/tvo3vCJbNNSizxgpagPAxQ6zDnafg Ss0A== 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 dt2si715311ejb.863.2021.12.22.03.31.22; Wed, 22 Dec 2021 03:31:22 -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 B083E68B030; Wed, 22 Dec 2021 13:31:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 35EFF68B02F for ; Wed, 22 Dec 2021 13:31:05 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4JJrk03Q2vzQlW5 for ; Wed, 22 Dec 2021 12:31:04 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Dec 2021 17:00:33 +0530 Message-Id: <20211222113033.7132-2-ffmpeg@gyani.pro> In-Reply-To: <20211222113033.7132-1-ffmpeg@gyani.pro> References: <20211222113033.7132-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/mov: validate box size for stts 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PLUjvJPQQSJ3 --- libavformat/mov.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2cc9e699de..59ee7ed2a9 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2967,6 +2967,12 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_rb24(pb); /* flags */ entries = avio_rb32(pb); + if (validate_box_size(c, atom, pb, avio_tell(pb)-8, 8+(int64_t)entries*8, 0)) { + av_log(c->fc, AV_LOG_ERROR, "Invalid or incomplete %s box in stream %d\n", + av_fourcc2str(atom.type), c->fc->nb_streams-1); + return AVERROR_INVALIDDATA; + } + av_log(c->fc, AV_LOG_TRACE, "track[%u].stts.entries = %u\n", c->fc->nb_streams-1, entries);