From patchwork Wed Oct 10 23:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 10593 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:ab0:73d2:0:0:0:0:0 with SMTP id m18csp1462790uaq; Wed, 10 Oct 2018 16:49:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV6077ZmrulvmyGQo0nWxdu8UVmuaHZeZJVry5tCg21nmQt75VGLmICzk4Z0AoP6T1rXVnYDY X-Received: by 2002:a1c:2ecc:: with SMTP id u195-v6mr2539710wmu.137.1539215373129; Wed, 10 Oct 2018 16:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539215373; cv=none; d=google.com; s=arc-20160816; b=gLKjkbu7Vhqm3T++zi7hVQpJJggZ0I13wuxVzFDWJdGrA2G0S4MXsYTtnLEk55prGd PDtWYCWNMNciRY+BX5w0AFrG1sSG8ZecBPKh+/RqYx2UXbc1OA6e+ZZ3XmDwJ6uIXLtF 2ae8B0442GNXilYICcy6CZ2iru036P3Ql3804LmDMIWyLIAgo+HC/8/GCPVE75CuKZof jMM8YBkYtfHkeHQlcy/LlRx2wSUTAbicZL4AQsTBrwgs8367XsatmOg3HdS54kTpaXRx P06RWXpVtjC4kIpApcoF6SLWecQxX+r+TNPjTmkWau1DEfwHlrXFaDUZLY/x9gybbcfj jmTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=xeo9BbAgNPWpwiP8i2PKrhiLizyNaJVV6EZgBm0Y4CM=; b=AOqEcNwk1aLMP9+yVcBrcWe0JDcOs8C8Ga+pUAOBcW4o1de7amvh8yPa5qbuklmfFB Cn4VgTOwICB64qH2mNctcO+Y3Sza5xrNNZOzDfh5XDQgBsrOypisG3vKxPe2GF/nD2KJ DAhXsfbgpHCXeRKsZ5aBQAG+GN95V8K3i/hT2W+UeoapFAmt504ilgHn8O/KrPyFQwL4 NyG2kagN8PMJvpOwFOMQsvKBh5g0zA2+/9dlkvsz6mxNmuzo/cBujYC9wcWIESssZg/a b/9ydGB2dyXOfqeHR+DxeA/pLwkVCBaUREtc0C3BNA+4ivs59sox3gCEtJxLn/Qm5Sh4 xi+A== 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 77-v6si14121771wms.146.2018.10.10.16.49.32; Wed, 10 Oct 2018 16:49:33 -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 C6F8B68A245; Thu, 11 Oct 2018 02:48:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-1.mx.upcmail.net (vie01a-qmta-pe02-1.mx.upcmail.net [62.179.121.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DC30768A1A7 for ; Thu, 11 Oct 2018 02:48:37 +0300 (EEST) Received: from [172.31.218.44] (helo=vie01a-dmta-pe05-2.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1gAODs-0001Bq-ES for ffmpeg-devel@ffmpeg.org; Thu, 11 Oct 2018 01:49:00 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1gAODn-0000Uv-1Z for ffmpeg-devel@ffmpeg.org; Thu, 11 Oct 2018 01:48:55 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id lzol1y0150S5wYM01zonUq; Thu, 11 Oct 2018 01:48:47 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 11 Oct 2018 01:45:30 +0200 Message-Id: <20181010234532.5857-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181010234532.5857-1-michael@niedermayer.cc> References: <20181010234532.5857-1-michael@niedermayer.cc> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/ilbcdec: Limit indexes in create_augmented_vector() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" These limits are based on limiting done in WebRtcIlbcfix_CreateAugmentedVec() Fixes: out of array accesses Fixes: 10652/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-5638941487661056 Fixes: 10655/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-5699970020147200 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/ilbcdec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c index dc8f961bbc..76ecdf0e18 100644 --- a/libavcodec/ilbcdec.c +++ b/libavcodec/ilbcdec.c @@ -631,15 +631,16 @@ static void add_vector_and_shift(int16_t *out, const int16_t *in1, static void create_augmented_vector(int index, int16_t *buffer, int16_t *cbVec) { int16_t cbVecTmp[4]; - int16_t ilow = index - 4; + int interpolation_length = FFMIN(4, index); + int16_t ilow = index - interpolation_length; memcpy(cbVec, buffer - index, index * 2); - vector_multiplication(&cbVec[ilow], buffer - index - 4, alpha, 4, 15); - vector_rmultiplication(cbVecTmp, buffer - 4, &alpha[3], 4, 15); - add_vector_and_shift(&cbVec[ilow], &cbVec[ilow], cbVecTmp, 4, 0); + vector_multiplication(&cbVec[ilow], buffer - index - interpolation_length, alpha, interpolation_length, 15); + vector_rmultiplication(cbVecTmp, buffer - interpolation_length, &alpha[interpolation_length - 1], interpolation_length, 15); + add_vector_and_shift(&cbVec[ilow], &cbVec[ilow], cbVecTmp, interpolation_length, 0); - memcpy(cbVec + index, buffer - index, (SUBL - index) * sizeof(*cbVec)); + memcpy(cbVec + index, buffer - index, FFMIN(SUBL - index, index) * sizeof(*cbVec)); } static void get_codebook(int16_t * cbvec, /* (o) Constructed codebook vector */