From patchwork Sun Apr 22 20:20:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 8592 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp30361jad; Sun, 22 Apr 2018 13:22:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx49/ik0seQixy68Bze4NCCoWKyMMJ7gRORoi9kOQnhZRVEGNbcexvAr2uw6zi1o3riXpObND X-Received: by 2002:adf:b64d:: with SMTP id i13-v6mr15219203wre.262.1524428520831; Sun, 22 Apr 2018 13:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524428520; cv=none; d=google.com; s=arc-20160816; b=ICvW2v0v3kuM0ToAfLfITbj55UG9UBVRburksJ4pxwsnaMiOa4ABlkmzyL7lskaxBl ZBdT7wqTIoBBBzJLZ2khsxIURlKNixdQVhQJh20ZFiUaSMrtdCdR4zSpPOD92zeB9Cb/ dvXtUDdgcuU3u6ckidKznem5LiI61LOwihdFpIJl6KQRp9/MdmipWZV4NGdq0D8HqGR8 QU7Y9KmDX8pFyRBLmm7zR6Orz2xA9A33T/G4hCcZe2onTl2hOy2NoUNO/v6Sc9Eiafhm 9sGLYxe6ZVp0Ezp/3Z65knlWva+94PFqvDcVhkktohdx9hnhsHsQS6fE8mvKOiLECN2X FEQg== 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:arc-authentication-results; bh=O2eZTegEQSdLtp10NC0yyREiwHxtMyEk4Uz7xYHXHsM=; b=IZxQl3ZqYL9EKWlsGP8+GUPBH882M16i8jxMIzB/2L/Ew/IE7pBQ0B2VcNuwZCe4+/ qvq8lYYFXU98npbJg1ssAzbSVqCIGY2Fo3/RGjxnArlFNPPzTxHUTgiq6mkA3CHkyWaK D/kfZ0bvyr/Wtww1QRJTy9bW6KUq2th3FR6DKs5uLfWybYVfRwK1WxBc9J0rfecdx4ap A4ceLCGe4HsM3pJjrMI72mccbDRyJGh4eX/viBsuCJG9YTu83UnlKQkQqfvXGcVxDC8W S/d102gBrT2BRi+7QMvra523VNfsvnT0WNLQNhK+D8mqpMs+xjX6rCyHgHztrsz6KZJ8 bjsQ== 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 n76si4612375wmg.186.2018.04.22.13.22.00; Sun, 22 Apr 2018 13:22:00 -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 7A75E689F0A; Sun, 22 Apr 2018 23:21:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-3.mx.upcmail.net (vie01a-qmta-pe01-3.mx.upcmail.net [62.179.121.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 40C56689CB7 for ; Sun, 22 Apr 2018 23:21:18 +0300 (EEST) Received: from [172.31.218.50] (helo=vie01a-dmta-pe07-2.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fALUZ-00006W-0G for ffmpeg-devel@ffmpeg.org; Sun, 22 Apr 2018 22:21:47 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fALUT-0006kL-FA for ffmpeg-devel@ffmpeg.org; Sun, 22 Apr 2018 22:21:41 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id dYMa1x00R0S5wYM01YMbNC; Sun, 22 Apr 2018 22:21:35 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 22 Apr 2018 22:20:32 +0200 Message-Id: <20180422202032.21067-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422202032.21067-1-michael@niedermayer.cc> References: <20180422202032.21067-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/error_resilience: Fix integer overflow in filter181() 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes: runtime error: signed integer overflow: 197710 * 10923 cannot be represented in type 'int' Fixes: 7010/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5667127596941312 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/error_resilience.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index 25e54a535b..339042e206 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -107,7 +107,7 @@ static void filter181(int16_t *data, int width, int height, ptrdiff_t stride) dc = -prev_dc + data[x + y * stride] * 8 - data[x + 1 + y * stride]; - dc = (dc * 10923 + 32768) >> 16; + dc = (av_clip(dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16; prev_dc = data[x + y * stride]; data[x + y * stride] = dc; } @@ -123,7 +123,7 @@ static void filter181(int16_t *data, int width, int height, ptrdiff_t stride) dc = -prev_dc + data[x + y * stride] * 8 - data[x + (y + 1) * stride]; - dc = (dc * 10923 + 32768) >> 16; + dc = (av_clip(dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16; prev_dc = data[x + y * stride]; data[x + y * stride] = dc; }