From patchwork Tue Sep 25 01:56:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 10474 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:1286:0:0:0:0:0 with SMTP id 6-v6csp3127160jap; Mon, 24 Sep 2018 18:57:47 -0700 (PDT) X-Google-Smtp-Source: ACcGV63wf+R37tvpgjulov+tOjnZc6LxPNoyIdH98lLrPZQIBRAtGM5cy6ZNdCOJPSECecyPlOZm X-Received: by 2002:a5d:488c:: with SMTP id g12-v6mr996730wrq.0.1537840666934; Mon, 24 Sep 2018 18:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537840666; cv=none; d=google.com; s=arc-20160816; b=b3nT6npoJsoZ1qSrfMetcGUgm8eJQmQ9DHrr95mn++1qBRXRc9ma7qZJ1jO2/7WwXQ illBV/ZvkKAn/c5Ll1YIeHCxL4gww33PzTurbwVrXnO/7pLMJIsntENBWe4kEHitJtQG KCcfptOsA812mt2QD1CKInnoy9XGKHv3s78daosWqgW5AsQSxZ5WYeteryaikD1BBeto TuQSnlAxJPMJhF6Kry3e07nN0KnGsRJM36VPYXB8O+Pi1RHJ/5Jan8P5L8LKrVP2M9k8 BeS3sW4bZoqPS5bYAEF3DqUHXF1Ybt42/Dvvy3Mqfvke8aM/6U6RcsGeHOtX9/fWEJu2 3WIg== 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:message-id:date:to:from :delivered-to; bh=Az5oFRdN0vFWEVt7bxUJxp5eJ/u7zUK+lNHHvrRZXgE=; b=pv0w37QZYEK4C7L6hP9oMNSMBWfJM2mdKpl6PEpiT6tQe/OKjfAAF1wqVjhoA55vTf oaEkcILjNBX1qwAjdDWI/lAbogZVFVwYtgwFIazYp/bIlws2UZKcLRsu2zT/7g1R+VNx uscpj7+5g0MOLumL9FB8MRaJZtMwdUmPf1qnavnpy5ptARuzNL7HZajPcK1ZOtnAHU4Z 7IbzUYZA09VOU0lmySbrMG1/rElyQ+85NcxnyoW9/taNTIsYewuleAbw1DLxzhETDg+W 44v1tfDHfFyyl2Igg8+D7mJD0ex/42dsoHvxSdvdNr/xabGVeO37gSsy2Xked1g142UF CBbw== 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 n12-v6si831880wrw.308.2018.09.24.18.57.46; Mon, 24 Sep 2018 18:57:46 -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 D9DD268A138; Tue, 25 Sep 2018 04:57:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-2.mx.upcmail.net (vie01a-qmta-pe02-2.mx.upcmail.net [62.179.121.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3FF9E68A0AC for ; Tue, 25 Sep 2018 04:57:22 +0300 (EEST) Received: from [172.31.218.49] (helo=vie01a-dmta-pe07-1.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1g4cbZ-0006r0-Od for ffmpeg-devel@ffmpeg.org; Tue, 25 Sep 2018 03:57:37 +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 1g4cbU-0003OQ-0a for ffmpeg-devel@ffmpeg.org; Tue, 25 Sep 2018 03:57:32 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id fdxW1y00j0S5wYM01dxXJC; Tue, 25 Sep 2018 03:57:32 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 25 Sep 2018 03:56:40 +0200 Message-Id: <20180925015641.8566-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/wcmv: Fix integer overflows 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" Fixes: signed integer overflow: 262140 * 65535 cannot be represented in type 'int' Fixes: 10090/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5691269368512512 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/wcmv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/wcmv.c b/libavcodec/wcmv.c index 384ceecd32..ebd5ef66f4 100644 --- a/libavcodec/wcmv.c +++ b/libavcodec/wcmv.c @@ -113,6 +113,8 @@ static int decode_frame(AVCodecContext *avctx, bytestream2_skip(&bgb, 4); w = bytestream2_get_le16(&bgb); h = bytestream2_get_le16(&bgb); + if (x + bpp * (int64_t)w * h > INT_MAX) + return AVERROR_INVALIDDATA; x += bpp * w * h; } @@ -140,6 +142,8 @@ static int decode_frame(AVCodecContext *avctx, bytestream2_skip(&gb, 4); w = bytestream2_get_le16(&gb); h = bytestream2_get_le16(&gb); + if (x + bpp * (int64_t)w * h > INT_MAX) + return AVERROR_INVALIDDATA; x += bpp * w * h; }