From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A68624B580 for ; Mon, 8 Jul 2024 22:25:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E2D1268DCC9; Tue, 9 Jul 2024 01:24:28 +0300 (EEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 77CA868DC22 for ; Tue, 9 Jul 2024 01:24:18 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id BD9BF60004 for ; Mon, 8 Jul 2024 22:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1720477457; 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=u/kvRYIZsI9AL6rNOXoLTRMqM6Q1D/yTtrljbkFGL+A=; b=j7jx4z+jyIozPVDwiC40+T4lcrUZcdEKZLPy3h8YGXhYfanQQ25ThaNHEZu6REwpjzLVoq V0A3LxrtFAjwHoou8IqqSpYJW/ZY5GU/UfF0FvVdGZYXVijolgTFA1h4MsVlDjjZ8tp69s nxnGMuNBS2lXRh3ialdM+hZluzMSZz9T/zOe4HtI50/jDBOFqrtB+snGtSP41JunLzXNqr nXx+tdCoePpj0JyFZ+E67+w3b7ZjlTEgLUonuthFTO2qHiOiamYbbbcN6KwsDujZK3kccA Ij/8t779jcENARzRa5vPzezyKySdlO3uCD/fw0A4SCwJjFmzBhPNhFIq8VyDZg== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 9 Jul 2024 00:24:08 +0200 Message-ID: <20240708222410.773456-6-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240708222410.773456-1-michael@niedermayer.cc> References: <20240708222410.773456-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 6/8] avfilter/scale_eval: Use 64bit, check values in ff_scale_adjust_dimensions() 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Found by reviewing CID1513722 Operands don't affect result Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavfilter/scale_eval.c | 9 ++++++--- libavfilter/scale_eval.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavfilter/scale_eval.c b/libavfilter/scale_eval.c index 75ed503f15f..dc8d522b1e3 100644 --- a/libavfilter/scale_eval.c +++ b/libavfilter/scale_eval.c @@ -114,7 +114,7 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, int *ret_w, int *ret_h, int force_original_aspect_ratio, int force_divisible_by) { - int w, h; + int64_t w, h; int factor_w, factor_h; w = *ret_w; @@ -149,9 +149,9 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, * unless force_divisible_by is defined as well */ if (force_original_aspect_ratio) { // Including force_divisible_by here rounds to the nearest multiple of it. - int tmp_w = av_rescale(h, inlink->w, inlink->h * (int64_t)force_divisible_by) + int64_t tmp_w = av_rescale(h, inlink->w, inlink->h * (int64_t)force_divisible_by) * force_divisible_by; - int tmp_h = av_rescale(w, inlink->h, inlink->w * (int64_t)force_divisible_by) + int64_t tmp_h = av_rescale(w, inlink->h, inlink->w * (int64_t)force_divisible_by) * force_divisible_by; if (force_original_aspect_ratio == 1) { @@ -173,6 +173,9 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, } } + if ((int32_t)w != w || (int32_t)h != h) + return AVERROR(EINVAL); + *ret_w = w; *ret_h = h; diff --git a/libavfilter/scale_eval.h b/libavfilter/scale_eval.h index 2eb6970aad4..b4895284043 100644 --- a/libavfilter/scale_eval.h +++ b/libavfilter/scale_eval.h @@ -41,7 +41,7 @@ int ff_scale_eval_dimensions(void *ctx, * force_original_aspect_ratio is set. force_divisible_by is used only when * force_original_aspect_ratio is set and must be at least 1. * - * Returns 0. + * Returns negative error code on error or non negative on success */ int ff_scale_adjust_dimensions(AVFilterLink *inlink, int *ret_w, int *ret_h, -- 2.45.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".