From patchwork Fri Jul 5 00:21:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 50355 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp4006748vqv; Thu, 4 Jul 2024 17:44:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUqwMEteps/+yufxdl/pzLkmlrBGoZSotWEZPfdLV8eOk7f1yrCzjA5sWZcF1OLTn6VCCYtQOXkTiYlOiH5f+dBDH7m7ILhWSNSRA== X-Google-Smtp-Source: AGHT+IHYmCUOgsKHD/ny509DHL296SXLieHzqbOFkAbv7ovX95gzZuImiS2dFThkYVGcb6FRShCb X-Received: by 2002:ac2:4568:0:b0:52e:710e:e4d2 with SMTP id 2adb3069b0e04-52ea06327b8mr2371931e87.33.1720140251618; Thu, 04 Jul 2024 17:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720140251; cv=none; d=google.com; s=arc-20160816; b=SHZs5yoFB8uTvlish+C1DsbDEumkFQn0fCigRzfznCdFEV/B0cBfuVkZeL+kBJhTfN yfKA0qnew3c8XgD5A97OLIfjm9TL6LVEiaHHg45uKy0qDMw6PTnwhKTZwfmfdKqacX4u b2rVbxII3ooRLmeyMbOXcsHUxkRaleeBxxYN3snRcmpxX0fKbVlziaZYopoQc2t+T8Nr XjyRnQAv75nDYiKApZp3TdnJfgRNcqc5YX1h+3CZU41qlQYguCMPejs1NoPuf1Dl9VWQ f4LmQxT+K7RV0ltqEDj5/esvuaUXCb0JoKlECQuy2t2us5WVnR/WJ/vqQMo8Zr2xrkck 4Aig== 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:dkim-signature:delivered-to; bh=T6LQ+MC3nf1VVSElNeGSdOZC4C75+OAfEy91guixyOQ=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=GrAfxucVezICuORImNFIfpI3x//rjQtqGXz/4PNEGVyjLZNGRsXYuvXrnonmhZYb2T JdeOD4Uo1xVJNuNc9KJ/8CHrljZ3M5c0hfRXOiMXD8NP6hzCN4/96OSVBEv2JWLmDtsP FuSnjs0nk3vXKjIOWhoMSsSCcvUoEQL59lFnbBMurUAnxgHS/dcjd/YLysjVrQPdnhWz gZ93lt9JM9Z8ZJwEucs8jP0AkZRhEB9xp2TjBSjWOPNGXEusmNbwrvJYDA5nyW29msmQ JzMQ69AO3tVKNDOokY4R+mi0gVSZwFCeV/Ej//qABqDqvxa8tw6dhjPxAWHXvlP5r1YV sSWg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=lPWDeZnz; 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 2adb3069b0e04-52e7ab29f0esi4798263e87.397.2024.07.04.17.44.11; Thu, 04 Jul 2024 17:44:11 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=lPWDeZnz; 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 4CF1E68DB1C; Fri, 5 Jul 2024 03:22:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3134968DAD1 for ; Fri, 5 Jul 2024 03:22:04 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6C4EC240005 for ; Fri, 5 Jul 2024 00:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1720138923; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HYlIgFXivJjrpsNJ8ueFPpy6JcOktybHu8sLaEGkC0U=; b=lPWDeZnzA3lrNyCKGJmPkjRKwzUP1iyyarA/db23NmrJsYvgqdXU4kxJ93iFO//OPZA1DV CmtlURIIX9wqDhkwLqqWQEsGI0c5Gah3OLxNpYZH+Sncf2JFFydnh4xOWs+oVLQhtgBquZ 6VVQdjdPN7AnDurXWS/xdYIafKHVfUltLz6Pz/gSzs8lgAS7Sw8gkuLLqTRIsQ8VR7Isg+ Gj2TdZeQfik8baP5gsPD8vK5qjW4oiRzbnSqV6au0fGZNtMd/bIRr/QuLlELb+AbqdSW5f hmhp+VoxTqCejYGs5D2Vs4Fet0Fw++s0qbrYmKudbvgwjpTTgl/IONfynczdmw== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 5 Jul 2024 02:21:49 +0200 Message-ID: <20240705002156.1964272-8-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240705002156.1964272-1-michael@niedermayer.cc> References: <20240705002156.1964272-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 08/15] avcodec/imm4: check cbphi for error 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: K4ymkwvQYvkh Fixes: CID1604356 Overflowed constant Fixes: CID1604573 Overflowed constant Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/imm4.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c index 3a4ad8616f5..a6da8fcf95b 100644 --- a/libavcodec/imm4.c +++ b/libavcodec/imm4.c @@ -220,12 +220,15 @@ static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame for (y = 0; y < avctx->height; y += 16) { for (x = 0; x < avctx->width; x += 16) { - unsigned flag, cbphi, cbplo; + unsigned flag, cbplo; + int cbphi; cbplo = get_vlc2(gb, cbplo_tab, CBPLO_VLC_BITS, 1); flag = get_bits1(gb); cbphi = get_cbphi(gb, 1); + if (cbphi < 0) + return cbphi; ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag); if (ret < 0) @@ -273,7 +276,8 @@ static int decode_inter(AVCodecContext *avctx, GetBitContext *gb, for (y = 0; y < avctx->height; y += 16) { for (x = 0; x < avctx->width; x += 16) { int reverse, intra_block, value; - unsigned cbphi, cbplo, flag2 = 0; + unsigned cbplo, flag2 = 0; + int cbphi; if (get_bits1(gb)) { copy_block16(frame->data[0] + y * frame->linesize[0] + x, @@ -299,6 +303,9 @@ static int decode_inter(AVCodecContext *avctx, GetBitContext *gb, cbplo = value >> 4; cbphi = get_cbphi(gb, reverse); + if (cbphi < 0) + return cbphi; + if (intra_block) { ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag2); if (ret < 0)