From patchwork Wed Dec 28 03:19:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 39798 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3859422pzb; Tue, 27 Dec 2022 19:20:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXsEK1O1mq644eFo+CE3k3aX50LYidK6SpEAKL6mWmwcWyA1EXK1wZkInvUqgFhECJ1qAwcJ X-Received: by 2002:a05:6402:1caa:b0:46c:72fb:3810 with SMTP id cz10-20020a0564021caa00b0046c72fb3810mr25801801edb.41.1672197615185; Tue, 27 Dec 2022 19:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672197615; cv=none; d=google.com; s=arc-20160816; b=eEdzDfV7hMA7OhQJt/QK/Me/PGmy42gCHO9mpAzzNA2R6K5uWkqOtCJ+Ktv4alCm+v pQWeWIGriUewu5JTBY4HVb7XwsbYHOgsDJ+DlwnbJv/5z15mN10jHkeZumjXUQfW9Fhm JVT0e+byxAM7WQsuI9GeMkYR0uIJxbLui3APWn4SuNyjo2Eg812EVISyAwLDzo9uF4A+ w7dHGcnNRiM7ImiLa+0obqW99j2RgdSA69ya3urhp+/TS9w7MQQMvZOvoHO662ng+3zb /gTIua75bkwBCQxkNuRZnlILOVk3iNjSH2dTE71H+uwXgDvFRxnlxCt2IolRrDvqSRMf zCCQ== 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=qyyrTg3eH8QbDRb6LGZdMr/1+yHOfln3GoOkIxBFtBo=; b=Jth5ksirDCX5zoN2/SKRu1mFVS6003a8brbmM39s6Wxkfe63JPUB01YW/Y8gTlAwHt Mdp5qJ8xFIRNcmskuPSIb2wdL+TBUswM4QIyV9fl6aXSMgtwkDfpKtFGK4c8fTtS/aEP Y3VkSPGlN+ELlYJGl2mHeh/OZR91oVIFizTXrbfQBAKL23P5ns6VUS9Mvm+bho3d9HBc xQPJiSOa5cGIgLm+l7kT/4xjejxksiCXLJ8qiPbPH1nPom11w/0EpjZ2hUUk8VDIvz4U sEvSb982bZM3Vo2wP4fKc6TX5ApwuS/1EYIM97b3tUvJrS0l+QAPNW1CYnmTSgCkoNd6 Pkrg== 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 q3-20020a056402248300b00482f01ff579si9440123eda.131.2022.12.27.19.20.14; Tue, 27 Dec 2022 19:20:15 -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 2CB8068BC18; Wed, 28 Dec 2022 05:20:11 +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 63F2268BC0D for ; Wed, 28 Dec 2022 05:20:04 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id C5BDCE840F; Wed, 28 Dec 2022 04:20:02 +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 MWSg2eRtYUXs; Wed, 28 Dec 2022 04:20:00 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3D202E82F8; Wed, 28 Dec 2022 04:20:00 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 04:19:56 +0100 Message-Id: <20221228031958.26570-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <76674b9a-30ff-a43-6d51-8c74dca8fa@passwd.hu> References: <76674b9a-30ff-a43-6d51-8c74dca8fa@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: check index entry array size 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: Tv0XtqlDtotu Signed-off-by: Marton Balint --- libavformat/mxfdec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index e6118e141d..ad4ee15570 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1198,11 +1198,15 @@ static int mxf_read_essence_container_data(void *arg, AVIOContext *pb, int tag, static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment) { int i, length; + uint32_t nb_index_entries; if (segment->temporal_offset_entries) return AVERROR_INVALIDDATA; - segment->nb_index_entries = avio_rb32(pb); + nb_index_entries = avio_rb32(pb); + if (nb_index_entries > INT_MAX) + return AVERROR_INVALIDDATA; + segment->nb_index_entries = nb_index_entries; length = avio_rb32(pb); if(segment->nb_index_entries && length < 11) From patchwork Wed Dec 28 03:19:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 39799 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3859477pzb; Tue, 27 Dec 2022 19:20:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXus+iSlLSYpC7zHju687N6SIagVGARC3byQq0RHLk7x6ZnFTRtD5kRccyx1haLfM97IIpMw X-Received: by 2002:aa7:c709:0:b0:46c:d5e8:2fc9 with SMTP id i9-20020aa7c709000000b0046cd5e82fc9mr20125121edq.13.1672197624343; Tue, 27 Dec 2022 19:20:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672197624; cv=none; d=google.com; s=arc-20160816; b=e/01XwrW6susXlPgjuN7yad4LCZZHHmBqrodTRVIq/ZkP0CByvbNp3B3qWRTzz4qOf eJOhlM+SkyfW6mj/Zr1MYGX9kBknvhcWIg5NJSA/BCi4La3P2lLi2HI9RYVrH4Mw476c YROGYM20FXNeEk848/jYX5msOz/piQ4J5HaAOQ4jzNSYC2f+N1SSYG3qdms0d7F25BzE WLQ8b8MnNvoqjE4VYRstWY8uUrOmEb8iP+7k4hzlnJjs0EdDw70o2fOAVVlgBjG0tsA2 4L9gn2WPCK4wNq4vuxJoMwWW0VLggCYOK8q5UOVbpqgNLZph+ZjXQGAbzcWFn0BUz7s9 Y67w== 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=5zemUIbnlOgnyZ/4xhbwiXSrHOHb1mKy7O35UKay97U=; b=l386uyPNHTMFuEdgoL4QP++ClHGvG0dEE+Fb3JZfRVNuBM/gMlkwEliDDY4RCeY1t2 h2jHdl6yTZTkWZLany/eCtQuTVw6FypEmFlYi1NiZHdCLrpPOj/A9obxegZ4fWpY0kvg 9tUstYD1hN7IIDwPpRrik4dpIjmqedkf2WrOe47QEKOfcTU1pkqUkAJpGFbIiuw3LjgP htJYaPiwLP4nJmvm35DEl9AJeqNanczjtb8WMxNwHVAkK4FGEPB/0l/FFO76Y4xGDoPO LTzC7/TxSebnLBoU4iYMWKMTUN6MbT3UwUxN5aUEzNkjP9KhULz1y7RDjpVXJAqoOA1i EEsg== 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 dp18-20020a170906c15200b007e08e2619e7si12767651ejc.860.2022.12.27.19.20.24; Tue, 27 Dec 2022 19:20:24 -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 50C0D68B7FA; Wed, 28 Dec 2022 05:20:12 +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 D711368BC0F for ; Wed, 28 Dec 2022 05:20:05 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 51AE9E8410; Wed, 28 Dec 2022 04:20:04 +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 HgddK4zyLgbX; Wed, 28 Dec 2022 04:20:03 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 25699E82F8; Wed, 28 Dec 2022 04:20:03 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 04:19:57 +0100 Message-Id: <20221228031958.26570-2-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221228031958.26570-1-cus@passwd.hu> References: <76674b9a-30ff-a43-6d51-8c74dca8fa@passwd.hu> <20221228031958.26570-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/mxfdec: support Avid files with an extra index entry 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: +rbmoojxGYUL Signed-off-by: Marton Balint --- libavformat/mxfdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index ad4ee15570..2e61e77d67 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1991,11 +1991,11 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, MXFIndexTable *index_ta int index_delta = 1; int n = s->nb_index_entries; - if (s->nb_index_entries == 2 * s->index_duration + 1) { + if (s->nb_index_entries == 2 * s->index_duration + 1) index_delta = 2; /* Avid index */ - /* ignore the last entry - it's the size of the essence container */ + if (s->nb_index_entries == index_delta * s->index_duration + 1) + /* ignore the last entry - it's the size of the essence container in Avid */ n--; - } for (j = 0; j < n; j += index_delta, x++) { int offset = s->temporal_offset_entries[j] / index_delta; From patchwork Wed Dec 28 03:19:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 39800 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3859547pzb; Tue, 27 Dec 2022 19:20:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXu6oWc8DKSmPSHuWyhHS8+96XHj5PiHqqAnpsLjAeD+/5OYgFL1PjU0wZB6VlqgXRGOFqcO X-Received: by 2002:a17:907:d50e:b0:81f:fc05:2ba0 with SMTP id wb14-20020a170907d50e00b0081ffc052ba0mr21012199ejc.2.1672197634306; Tue, 27 Dec 2022 19:20:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672197634; cv=none; d=google.com; s=arc-20160816; b=WTfn8naFOfzTQL0pvvRZngj+4dmsnZ8rvcnnXiaPq6FRM44hWIaJABDO6eLhe+ezDy eUUQ8w3Fu1Cc7CsZqj/IXV0Jh0p72BeBgCfjD3tkRCs+2eWPvnMBwHrp/+wdb8+12gC5 1w7ZyvmZVxouiMBX869zKMLkkWKWY09qeSM97jDQgFzXQT+Os1QHdEMKgFSFvAQHau5m P5GxR3iiHjgVgL989tI/DkQgV63OYUD6v5NLcUglA9toylLFFGKHzoyTYbm4jssSvSkr 1nKac0ZjqKDkUzEFNTDYfmZJw88iJj2NRVqYmuyuMvMHYZryzVRvWlmN5z4YwFf20zHc xSHw== 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=2PJuxw8N7hLjw5zpFFxTKccyg8x5uy6yKSx2C3ipvFE=; b=sb1pMXjNU24QT0k/jAj3wSo41VmQHOIK2CJxg/WJH0/TEzAamSLnLa+tky/M8etd8f c04CIT3FWkIJK/I6+8IaQxvUYDmp4Skw8N9+sSh4+P31+tkueDLCY1UDVCnWtFz41saR GnSB0hfyjpdrtz1KxK+zNt8pPlUEwWP9p+CBAtYjtOdJYgHekJ05tR/uNq3R5C4ZrxIn UI8LgO0PY6Y8eRlrmZZzBzRJJI3A7L0Ak3p62mZBFP8AddNu2/Gp6n9ulYRlaEGuQbut gUP+wyjbPtm5Q+p91oqpynve6Y2t5yIzn1G9jba8oEkW2d147Fpm7RFpt4uZCzDCDsFs ZAkA== 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 xc6-20020a170907074600b00780e89aecd1si11834592ejb.849.2022.12.27.19.20.32; Tue, 27 Dec 2022 19:20: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 639E268BC6E; Wed, 28 Dec 2022 05:20:15 +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 E460268BC3B for ; Wed, 28 Dec 2022 05:20:08 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 6E1E4E82F8; Wed, 28 Dec 2022 04:20:07 +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 uuej1nIHVPD8; Wed, 28 Dec 2022 04:20:05 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 84836E8411; Wed, 28 Dec 2022 04:20:05 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 04:19:58 +0100 Message-Id: <20221228031958.26570-3-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221228031958.26570-1-cus@passwd.hu> References: <76674b9a-30ff-a43-6d51-8c74dca8fa@passwd.hu> <20221228031958.26570-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avformat/mxfdec: check number of index table entires more strictly 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: BHSGpyFg6aGQ Let's ignore the index table if the number of index entries does not match the index duration (or the special AVID index entry counts). Fixes: OOM Fixes: 50551/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6607795234930688 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Marton Balint --- libavformat/mxfdec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 2e61e77d67..0dc61648b1 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1937,6 +1937,14 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, MXFIndexTable *index_ta return 0; } + if (s->nb_index_entries != s->index_duration && + s->nb_index_entries != s->index_duration + 1 && + s->nb_index_entries != s->index_duration * 2 + 1) { + index_table->nb_ptses = 0; + av_log(mxf->fc, AV_LOG_ERROR, "ignoring IndexSID %d, duration does not match nb_index_entries\n", s->index_sid); + return 0; + } + index_table->nb_ptses += s->index_duration; }