From patchwork Tue Aug 4 08:46:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 21470 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 3552344BD82 for ; Tue, 4 Aug 2020 11:46:32 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 19A7F68BAD2; Tue, 4 Aug 2020 11:46:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-40136.protonmail.ch (mail-40136.protonmail.ch [185.70.40.136]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2B67D68BA93 for ; Tue, 4 Aug 2020 11:46:26 +0300 (EEST) Date: Tue, 04 Aug 2020 08:46:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail; t=1596530785; bh=0DQh+UUOOm+/rgWWi9ghl8iQT0ujLZuCkaQPskh1SFc=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=TZqzkQ8bt5+sglNYy3QpUIoyAL02n04NOU/JQYYXWM+tsa7D4FkN0cieFhtWqdVM1 PTwZdoL//l0CzHTgZ0U5Khkm83DUJXGx4ZdxlbUe0aQgGEnug3sI7ImSBxXGZA4Gkl ueGNbOno9LMINHC3Yiy2OzkzYJe/vbJpIBwpER6k= To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200804084552.1974751-2-zane@zanevaniperen.com> In-Reply-To: <20200804084552.1974751-1-zane@zanevaniperen.com> References: <20200804084552.1974751-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mail.protonmail.ch Subject: [FFmpeg-devel] [PATCH v2 1/6] avformat/argo_asf: check sample count in demuxer 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: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Zane van Iperen --- libavformat/argo_asf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index 3339425244..9de64dfab4 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -27,6 +27,7 @@ #define ASF_TAG MKTAG('A', 'S', 'F', '\0') #define ASF_FILE_HEADER_SIZE 24 #define ASF_CHUNK_HEADER_SIZE 20 +#define ASF_SAMPLE_COUNT 32 typedef struct ArgoASFFileHeader { uint32_t magic; /*< Magic Number, {'A', 'S', 'F', '\0'} */ @@ -39,7 +40,7 @@ typedef struct ArgoASFFileHeader { typedef struct ArgoASFChunkHeader { uint32_t num_blocks; /*< No. blocks in the chunk. */ - uint32_t num_samples; /*< No. samples per channel in a block. */ + uint32_t num_samples; /*< No. samples per channel in a block. Always 32. */ uint32_t unk1; /*< Unknown */ uint16_t sample_rate; /*< Sample rate. */ uint16_t unk2; /*< Unknown. */ @@ -158,6 +159,12 @@ static int argo_asf_read_header(AVFormatContext *s) argo_asf_parse_chunk_header(&asf->ckhdr, buf); + if (asf->ckhdr.num_samples != ASF_SAMPLE_COUNT) { + av_log(s, AV_LOG_ERROR, "Invalid sample count. Got %u, expected %d\n", + asf->ckhdr.num_samples, ASF_SAMPLE_COUNT); + return AVERROR_INVALIDDATA; + } + if ((asf->ckhdr.flags & ASF_CF_ALWAYS1) != ASF_CF_ALWAYS1 || (asf->ckhdr.flags & ASF_CF_ALWAYS0) != 0) { avpriv_request_sample(s, "Nonstandard flags (0x%08X)", asf->ckhdr.flags); return AVERROR_PATCHWELCOME;