From patchwork Sat Sep 17 21:15:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 37992 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp389487pzh; Sat, 17 Sep 2022 14:16:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5JVRHMXj54Sr8qkZ1SiVO87YBWGd6vez/tG57e2Ca2rN7rkXNHxDWVWOGVodz7eg4Y3u9y X-Received: by 2002:a17:907:3ea7:b0:77e:6057:3e1a with SMTP id hs39-20020a1709073ea700b0077e60573e1amr8033101ejc.470.1663449415774; Sat, 17 Sep 2022 14:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663449415; cv=none; d=google.com; s=arc-20160816; b=mO5e2y6nN0HBM3KtzG4a53/V+jrOO5cfUNAxQwu5YG/kFKLtxDhV9e2xQOHtYxS0t5 eHM/mK7hh/JAvEBPD3hwINHSUk4e9tO9EgUUqAwUWmtLewkpEiDHv/YXnEycLOFvnPc3 CWm3z1Yn8Nd2vtn87sVqbddygrGNVmRtRFwMVHuAKi2RUctmgaEbSTG50UwMhUwPo05i VmK+NSB5B41sdMqlhS1YZiMfj4Q7xi1IYcFdNw7mdifzESDpq9Rj450D6nxwMXUR/FEH 3YUWD146obPfmkJC8Nxp6ymu5nfKEnJGn/LXNJh8zkj1Mbd+F7GApYghmuUPPhgafOQD c8BQ== 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=YXb3j+c5sxwFknKpm1aQPp2ZaVjLLc9w96xUz+ikv3I=; b=GbFPuCk2xJQc7rPvrlNIWq+Dxc8UfQS/pGijV80V/TVyx7mJDodETVCqDHJq/UA1I6 wG/pbI68TpMWXU03R/IaEAk3H88nCBqah6wgJSG44wi3FLPelpdVwplld/FqkW8AFaLt LdFzQy9u2ZFQnNWVlLBlxTcbe3NGs0EITrENU6M0NxkuP+32MHyCENEi+iENpvg5mURB R8z0AnFV6mi7ciZRNIuj9Uy7XucAwpIa1Qc985vfvGq5gIEeEvdvNeAFxBnEaj19yxFY BstRM/+Qdo5WVZhx7EFF62BMSO1Ay97dCC2wMFlTGlVuSM1QS4WVusga5obrAzDi2og7 13yg== 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 b7-20020a056402278700b004469a602b4esi5875647ede.66.2022.09.17.14.16.55; Sat, 17 Sep 2022 14:16:55 -0700 (PDT) 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 1457568BBD8; Sun, 18 Sep 2022 00:16:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-at03-1.mx.upcmail.net (vie01a-dmta-at03-1.mx.upcmail.net [62.179.121.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A799C68BB5A for ; Sun, 18 Sep 2022 00:16:00 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-at03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1oZfAO-00DrNV-7K for ffmpeg-devel@ffmpeg.org; Sat, 17 Sep 2022 23:16:00 +0200 Received: from ren-mail-psmtp-mg02. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id ZfAOoPQVL8s8UZfAOoEt8L; Sat, 17 Sep 2022 23:16:00 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg02. with ESMTP id ZfAOoy3fMbZLDZfAOoILBk; Sat, 17 Sep 2022 23:16:00 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.4 cv=Ufwy9IeN c=1 sm=1 tr=0 ts=63263910 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=h7uK-zp-ZIHwQwwoGEYA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 17 Sep 2022 23:15:55 +0200 Message-Id: <20220917211557.11547-7-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220917211557.11547-1-michael@niedermayer.cc> References: <20220917211557.11547-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfP7EFXbA4RImoSaLqAEXsIfCQQWF1iv1q3/3CzxnAESK3zDz/oS0lpzN8g1V5JcDXJiVR20Qolimjri2bvRUjBVsq5Ltb6KJ0qUEndAUJdy2EatOGJ5e VdmfEJETppJHJF7eX5GGMqqUJCIUasxzZhHqVI8X7q6vey2whuTLqAfMvEghyLhFDFxfBNqOgUKb9g== Subject: [FFmpeg-devel] [PATCH 7/9] avformat/genh: Check nb_channels for IMA ADPCM 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: hm4rnCRRWcmv The check could be made more strict Fixes: signed integer overflow: 36 * 538976288 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-6539389873815552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/genh.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/genh.c b/libavformat/genh.c index a25d4d625a4..1f707b55552 100644 --- a/libavformat/genh.c +++ b/libavformat/genh.c @@ -78,6 +78,8 @@ static int genh_read_header(AVFormatContext *s) case 0: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break; case 1: case 11: st->codecpar->bits_per_coded_sample = 4; + if (st->codecpar->ch_layout.nb_channels > INT_MAX / 36) + return AVERROR_INVALIDDATA; st->codecpar->block_align = 36 * st->codecpar->ch_layout.nb_channels; st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break; case 2: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK; break;