From patchwork Thu Oct 14 22:13:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 31118 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp7645877ioa; Thu, 14 Oct 2021 15:14:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyGV5vn4MWmZKXEZIv0Sx5n2IGV4VqpwLkEdct+vG5P298GYPY14nnPSqfxWNURHouS3L4 X-Received: by 2002:a05:6402:2756:: with SMTP id z22mr12579749edd.264.1634249679805; Thu, 14 Oct 2021 15:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634249679; cv=none; d=google.com; s=arc-20160816; b=K3wifAQAspZDNDo/+lgjaAARUquzI2/HFY+CETj/93mfpJGtcLcy4jGKs818xJH+9x +xGW0Iz0+pmCrbyjaW3b8PLU+BN1THULAfXKDhJQj+00ntDC0hYcuL+iUnNQauFZ031g Ci5CT6MXfd4pXQx/EnG4NtA3reF/qSjWFZB5skCpZRt878E9DxLpjw91/Y2+nEk0NBuY nKEcFelyvcp+zfiy+hPJZIcwWbtZZl1b8RhfSeEJzh5iOxfMth6MjSnldHp5MrbPeSV9 Jc/+JnejZ2AkahdE0KQEgtVZ0RitXjjWe958r4l9QvNGk38Ik41+DCHmFXL4qWQQjwO5 OM7A== 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:message-id:date:to:from:delivered-to; bh=onwPxxbXwgfGXIqjLqSo6RViF0TVZncIIxiIf1o4qRw=; b=cgd79g8zUdCg4CcBT53xRdpOTJ9in+3TnhniPhS+Eq7CkCYtnsof5d62ixY2BBMkya nLt4EnxSlW4Pe8HfzjTS3NSqgVbT0Isrfzdhu8jjh2BdbQ0hgKGH/yDQKiNkS5Wqt9PX j8YsUtPTmub0SI1uSBc/7AAt5DFxuYjKl33skplPDc8Dt7WuQcI5c3ZGVBGciWg4bytE vq5GPMQcmmEMp3BIR39kMnaJlvc0ClU5HYYV71F16KunjCXad479aSHirBUIWrV3jJT9 PlIuTyORupsGckcGasqY/VNRfP79C3JFYQP4wo+WF0Lxoy1RvYChAxFOFJh+mExIk+7Q H6xA== 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 jg12si7629830ejc.536.2021.10.14.15.14.34; Thu, 14 Oct 2021 15:14:39 -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 AFC1F68A8F3; Fri, 15 Oct 2021 01:14:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-2.mx.upcmail.net (vie01a-dmta-pe03-2.mx.upcmail.net [62.179.121.161]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C55C168A101 for ; Fri, 15 Oct 2021 01:14:24 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1mb8zY-008wVP-0C for ffmpeg-devel@ffmpeg.org; Fri, 15 Oct 2021 00:14:24 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id b8yamqDNYSgGFb8yamFWMi; Fri, 15 Oct 2021 00:13:24 +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.3 cv=f8Q2+96M c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=NEAV23lmAAAA:8 a=D7-PzmVGEBqAa0GGoK4A:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 15 Oct 2021 00:13:22 +0200 Message-Id: <20211014221323.21096-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfCtLTRDVyIG1bNTUOSe3d85PuK+3FiqtFAjU6isP9aUD23kow7asq38nBWUfZcgsBGjmRKEoN4RGqFRtLIbWlbAtS6D9+8Fp3xpS8Ipt/2/vSiXeHuW3 0z0JnnWIcbjpAqYkjxjr2cE4I1UqP33NwfgbWNse4QcyGGgwserd0V9c Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/speexdec: Check frames_per_packet more completely 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: gkkrH4mKERL9 Fixes: signed integer overflow: 2105344 * 539033345 cannot be represented in type 'int' Fixes: out of array write Fixes: 39956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-4766419250708480 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/speexdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c index 4c50f54f27b..05f084de2e5 100644 --- a/libavcodec/speexdec.c +++ b/libavcodec/speexdec.c @@ -1428,7 +1428,7 @@ static int parse_speex_extradata(AVCodecContext *avctx, return AVERROR_INVALIDDATA; s->vbr = bytestream_get_le32(&buf); s->frames_per_packet = bytestream_get_le32(&buf); - if (s->frames_per_packet <= 0) + if (s->frames_per_packet <= 0 || s->frames_per_packet >= INT32_MAX / s->frame_size) return AVERROR_INVALIDDATA; s->extra_headers = bytestream_get_le32(&buf);