From patchwork Sun Dec 18 17:08:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39723 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp3343098pzb; Sun, 18 Dec 2022 09:08:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4iQEaWII+REv1IYFpAIT/fC38t6sXuiU/KhH4Wq4FbwOnuu0wX9tQwc9F/vopJBbY5WtCe X-Received: by 2002:a17:906:51d6:b0:7c0:c312:acaa with SMTP id v22-20020a17090651d600b007c0c312acaamr34413549ejk.49.1671383334194; Sun, 18 Dec 2022 09:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671383334; cv=none; d=google.com; s=arc-20160816; b=K6qMHWD/LMkxCKXtJeEOn8X5nBvJ/R8Pv/hU9L3467JWJkcyq7NekJMaVSD1Ceg/CR KDuKqiR3uhmRI/Hafbp1FGHYEikDXgstUvK5j9KXTy4cpGnzPcN7TNjG6xuIanwYv9UM 8Ji81FFzJR0VXH1xrf/9/SdT6zxZoaA8/4pYY6ZBQOTd0HCvPxZAEHjGVDTsDLQZFwy5 09mHUyHJc1en3gh7gwrDh79v7DSAw1bDNnTz0wgJdut6W+kccIyocQDiagnUYegXwLMP uTsq/3+WZF1Q7B/jQ3gYmmbua+B9dqI+IwwWE2a+NKsqlDW3awtINdCebk5rlyZFqjMd DNUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=3o8lgrj1mnEnvs+gRlFQYGlCPZ5stR7EtqNlZ05jJM4=; b=RM2v4rJuweHABErcVTh88aqY1Nz4Kdw/m4y5LxO8QwPqZWdi0x4FTRyjRSmY+3Ifsj sbB8G0U75tkiviv/GSx1HAHO3g/Z1xTxZGrfU8iWwacBOaPtahwvoCISX3b04+51dUjk mLfaOzlLSjjot62xQtj2/HKmI9OVjTg/6oiKs9XnvyGNF11gufsLGxgdXBzVQdOoTnOD zLDg8sZ4d4/6N0x4IJwhkP1BDsAAxx+HJ3KdSdWXXEGnE3glewswhW2vcFDalHbXz5Xb xZwpfNV0SSv2R8Atb+i96vjWun8yV6Os6Hlu6k4oIpBRKQlZAYmBoR4MsjroWRqMiLZP Ea2A== 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 g16-20020a1709065d1000b007f1501a8c3esi4206565ejt.511.2022.12.18.09.08.53; Sun, 18 Dec 2022 09:08:54 -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 A8C1A68B5A2; Sun, 18 Dec 2022 19:08:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D8B9568B8D2 for ; Sun, 18 Dec 2022 19:08:31 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id D73C2240002 for ; Sun, 18 Dec 2022 17:08:30 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 18 Dec 2022 18:08:21 +0100 Message-Id: <20221218170823.32130-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221218170823.32130-1-michael@niedermayer.cc> References: <20221218170823.32130-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/apac: Sanity check bits_per_coded_sample 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9PCoHbYgsDGN Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' Fixes: 53931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APAC_fuzzer-6072913738727424 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/apac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/apac.c b/libavcodec/apac.c index 030f81adce..2501209681 100644 --- a/libavcodec/apac.c +++ b/libavcodec/apac.c @@ -75,7 +75,9 @@ static av_cold int apac_init(AVCodecContext *avctx) avctx->sample_fmt = AV_SAMPLE_FMT_U8P; if (avctx->ch_layout.nb_channels < 1 || - avctx->ch_layout.nb_channels > 2) + avctx->ch_layout.nb_channels > 2 || + avctx->bits_per_coded_sample > 32U + ) return AVERROR_INVALIDDATA; for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {