From patchwork Sun Jun 9 15:47:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 49755 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp2068989vqo; Sun, 9 Jun 2024 08:48:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWbtVU4yHQyjGeBi6o6jvU/ZTWcEF/uOyT288cRh49I5e9Xv5UefWhFm1RkNjI9F7yQeGgh8rACXxO1n/tHiLAAO0hCVbIVnpVY6A== X-Google-Smtp-Source: AGHT+IFY/UvVgt+7k7YqryQnkVAIdlUasJR9CgzuToVgUnU02gQ0sOik60ofWcumYZGyUp0K5DdX X-Received: by 2002:a17:907:76d8:b0:a6d:fb80:cbb1 with SMTP id a640c23a62f3a-a6dfb80cc85mr394959566b.60.1717948116655; Sun, 09 Jun 2024 08:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717948116; cv=none; d=google.com; s=arc-20160816; b=Nu9axGLWRpqrR+Fdu/xU+Tvwjb6L49u/sTb5OYCzLkoEbpguIh/cJlkmlnnRq0UWH1 Ir9wiPFMth8ABz5CtnyCFnACwxaBYCZJD0fzfRKgdMm3C95T6p/EVzn7jxpl09jPNeWe yv/CPBRjNBspSbPBnYUe4gG72teg93nAjqYW2YDBR7p2B+uhsPgNorZtGHWrnZgpHoYu kom8qKCoVhgnDsN3qltStpD0Gm6wFY+1o56puN70Inu6prvcRMSn4mRCEcuAP2vFiiM6 okN4Dqhh0ICAFhqL0p52aQadPZbfHJC/XViyDkI5A29yhiXULqoA/S7h5ErDmGzp012B AKYg== 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=0NCB1j1Z6vpci6hGP6i7XZRxrk4uFOovJuSaphfVDbw=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=SyJuuwoTmesJep0qsOioOFvvu7/g+EMoo5mImw23RDLKDH7RtcpbHwrVLjAVeQSsbS E373vUmT4Xx9cN11t3r0NlmXjyuzkgbagF2cOKxvRfu4BJa2vOnvClEIl75Yq5ge3Vbb wZ23Jyz5j4sMDalcQHsSUNeQoBF3SDky9EcHZbV3SZ7jxMKrZEx0PKxp8rDoY0GKZUUc agmWQTouyGn4CNE4VgoYq8C4lENl8tDPSOfxa16mu1YanmHu2ZrRbwy3bHq3dmUxyhof ouXM/yt9lNd4KxPuRhFgfqKGge5LbXMY9++EhZMfObagxVouGqmxyTd9f2lf6nx0blJw gGPg==; 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="U/kYDwi9"; 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 a640c23a62f3a-a6eff8a389bsi168068566b.144.2024.06.09.08.48.35; Sun, 09 Jun 2024 08:48:36 -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="U/kYDwi9"; 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 03F2F68D63B; Sun, 9 Jun 2024 18:48:02 +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 24B4268D59D for ; Sun, 9 Jun 2024 18:47:52 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 82190240004 for ; Sun, 9 Jun 2024 15:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1717948071; 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=YwuBRNnaqYA7k5bGrar+c9zj2cQjplHR6LhtggzjFeU=; b=U/kYDwi99mYyE0YMW+euFheDTtAu61uIUO6Ekm1z4sNJtX3fcWjp5EzkMSh7JexL9ax7ot MThyTq7ODVmMFnZFmXQNVrGGmiPIzQ0xjpcSXln7lWvvOFiY5NvOObS03xgwX0818XcetC WkVlfktxkdv9VCbSky/KkGCKNClXdpqaRnuFd33bTIYagKNuWFjrAym1Q2Exp8SR0kPi9A Xpp+PxqcPnqTUPywvdBaRAjmT1UJU03ptyaT8GHJ0Pgysu2MYwmWMSB54x/THX2LQdL39N a8tk4ukYr6XuNKu0vI06Qn0Hm96YHFbt6ul5/4nD2LSg6eZe+EzghaBSHWffFQ== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 9 Jun 2024 17:47:45 +0200 Message-ID: <20240609154746.4173264-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240609154746.4173264-1-michael@niedermayer.cc> References: <20240609154746.4173264-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 5/6] swscale/swscale: Use ptrdiff_t for linesize computations 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: Rhm0vRLR+mzJ This is unlikely to make a difference Fixes: CID1591896 Unintentional integer overflow Fixes: CID1591901 Unintentional integer overflow Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libswscale/swscale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 2795429b6c3..7fb24ee04bb 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1173,7 +1173,7 @@ int sws_receive_slice(struct SwsContext *c, unsigned int slice_start, } for (int i = 0; i < FF_ARRAY_ELEMS(dst); i++) { - ptrdiff_t offset = c->frame_dst->linesize[i] * (slice_start >> c->chrDstVSubSample); + ptrdiff_t offset = c->frame_dst->linesize[i] * (ptrdiff_t)(slice_start >> c->chrDstVSubSample); dst[i] = FF_PTR_ADD(c->frame_dst->data[i], offset); } @@ -1234,7 +1234,7 @@ void ff_sws_slice_worker(void *priv, int jobnr, int threadnr, for (int i = 0; i < FF_ARRAY_ELEMS(dst) && parent->frame_dst->data[i]; i++) { const int vshift = (i == 1 || i == 2) ? c->chrDstVSubSample : 0; const ptrdiff_t offset = parent->frame_dst->linesize[i] * - ((slice_start + parent->dst_slice_start) >> vshift); + (ptrdiff_t)((slice_start + parent->dst_slice_start) >> vshift); dst[i] = parent->frame_dst->data[i] + offset; }