From patchwork Thu Feb 15 12:46:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 7604 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.1 with SMTP id c1csp2080534jai; Thu, 15 Feb 2018 04:46:22 -0800 (PST) X-Google-Smtp-Source: AH8x224qRIbFjVrc3m+roMZORqln94Jh2/sibswT1OXdxIyBLgFoVoANshX+72EiSUu+Sg3fSEGp X-Received: by 10.28.217.129 with SMTP id q123mr2118398wmg.73.1518698782201; Thu, 15 Feb 2018 04:46:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518698782; cv=none; d=google.com; s=arc-20160816; b=ZKaVa/qIn0/z7/3m4vxmJh0kDLcSZzCC9uBJWfsIjdhFpxfxi3APQaKPo2XHHIClJ7 enWe1s53ngrTzUoWaSRl4mjKx3faUPRNLxSWRA+3YmUzT3CM1IUPUGM63RSj3SUm4iVM Xvc1XF28aNojgWdPf59HfucfTEcuJJPwkvnJazYKIMqB5iUPPHsqsKI+kdrRadsxYUjN C9AeDlWcHzMv5MiDpSLo3DhCUY869/dGKGrzN/uyXqZEchbRt9FnEn/fsE6xNKMyY0oR K2mUZ02FJ/4vVHwN7Uc8vu/+R0xxZlvuNuDS3mdX/k2xZgbl7Nx9gOHtBNeao6iN/Xps lL+Q== 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 :arc-authentication-results; bh=4vOcg4ObqF17X39j9LF+AZY+6LHaZXU2iHVyldv7AYk=; b=PBbIkbQavmhg0e6ZUeMw0NOpAO6/GCww0OHDZo862zOCt5ER0nnqAx8rFRrqnFRoJf /GzI4O62ktpwlBGnS5nOLw2fhnd4kbLc3Ogp8umPZw9fkITQ8yDlKlL4mQci41o/hy4w lNo2fMwBW/m1TyeYIzxUu3STYAmwZZiPAxv5vwMhWlPCvwe8Za4RNN0vfd5WxwOCS16e StxiTXtn+5S7BJTgUr3tjnSMz+lHhNfxmYQScE1JuwwaKJ1CV2l+qMqoLlV5bVXoN61Z MT75zcOgZcdX0pOD0rkodCgjVtXqaedFgiMPUOiGhgnnpOrHA2osgeGiyARJZkmn79Xc EaJw== 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 a204si8312315wmf.110.2018.02.15.04.46.21; Thu, 15 Feb 2018 04:46:22 -0800 (PST) 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 55321689EC6; Thu, 15 Feb 2018 14:46:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-1.mx.upcmail.net (vie01a-qmta-pe01-1.mx.upcmail.net [62.179.121.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7E4BE689B7F for ; Thu, 15 Feb 2018 14:46:02 +0200 (EET) Received: from [172.31.218.38] (helo=vie01a-dmta-pe03-2.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1emIvW-0005Af-9U for ffmpeg-devel@ffmpeg.org; Thu, 15 Feb 2018 13:46:14 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1emIvQ-0006CK-Cc for ffmpeg-devel@ffmpeg.org; Thu, 15 Feb 2018 13:46:08 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id B0m71x00D0S5wYM010m8Pz; Thu, 15 Feb 2018 13:46:08 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 15 Feb 2018 13:46:06 +0100 Message-Id: <20180215124606.5160-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.16.1 Subject: [FFmpeg-devel] [PATCH] avutil/common: Fix integer overflow in av_clip_uint8_c() and av_clip_uint16_c() 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: 5567/clusterfuzz-testcase-minimized-5769966247739392 Fixes: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavutil/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/common.h b/libavutil/common.h index 5e0382827b..0fffa67714 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -158,7 +158,7 @@ static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, in */ static av_always_inline av_const uint8_t av_clip_uint8_c(int a) { - if (a&(~0xFF)) return (-a)>>31; + if (a&(~0xFF)) return (~a)>>31; else return a; } @@ -180,7 +180,7 @@ static av_always_inline av_const int8_t av_clip_int8_c(int a) */ static av_always_inline av_const uint16_t av_clip_uint16_c(int a) { - if (a&(~0xFFFF)) return (-a)>>31; + if (a&(~0xFFFF)) return (~a)>>31; else return a; }