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 1BAAD49439 for ; Sat, 11 May 2024 20:31:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3813668D41C; Sat, 11 May 2024 23:31:41 +0300 (EEST) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B47C668B32F for ; Sat, 11 May 2024 23:31:34 +0300 (EEST) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6f4302187c0so2912722b3a.1 for ; Sat, 11 May 2024 13:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715459492; x=1716064292; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XTzlDifZD+KIldu6eCMtJs1quHARMbLTd38RaRQH2ks=; b=MHpOPSdv07CFhs+5/sjs9PFp5Ky+DmJrkVz29DLrYP4aVxcCB7jzzfUzXuwHuPdEIM 2VOjQYGuRJnPESJAluIq8WU19ZDbPr5Crd98gk0ZvQ9AxiDiq3xfFZqvOLVBREMoztCD jxZHBKEfZouqBSr8M3L9t78HTFSKMYvKBOQAgfUhVmF2kQK0fEBpjmKl5IIAxuxtnggw rgn6bYe+y7vrWGWSBmGhm94NtfCKeXrbZK6/WNpIIevQRP67fWMgdwQh6AuUX0V6Na0i cMJVW9Kc0so+G67nROgToNqMqg3CqM3xSc8Pn62UTs6UOtFShIqZyWC4IvJ3FXo/7z/k EhyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715459492; x=1716064292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XTzlDifZD+KIldu6eCMtJs1quHARMbLTd38RaRQH2ks=; b=NRb70neIUK+rUvUep5QEGj+RDeKKqIWbl7M4Ut+BsThiX0rSXxiw2JVaNXkYhi1oBa NZaqlLx/SOewwfBP+wiqv99JjKrNzQd44LtSCEm4x+TsqY6qPqTw/urEhEr07TCyH1cC IIZ2irCO8p1RNi6aZBl5VZ59/PlREHOP2eev1OZJkDF3xbFaDWA8LpedD5LWHZFYBeXr UCo9CzppkfshsfKupomOeQrzvX4Sg/q10pMoWS8tPKjwcRBnseff33o5pbdVF9ghw6mV rm24fK19Vpcu7dCjU4EFWOeo+yqhRQg4roVwSkDOc/d02MPEmDhwvrQPtqsr3Wp+iN10 xJ/Q== X-Gm-Message-State: AOJu0Yx4OFx/T19TsUstRaJGFQ4CqZHcuql+bk9bZZvPehqClLjIXH87 UeKiS6lIP8LAxLVtYtHJ9c688pGlUp0p8i9K0bw2HlA7usnG5qkjDLuHkA== X-Google-Smtp-Source: AGHT+IGfqT31rNQ25+PHtXXcN1DlXMJBLr+qTexHg1cPPwrNnw8UOxjRMRedisqNFjWYjua9WDAygw== X-Received: by 2002:a17:90a:134b:b0:2af:42ce:54f with SMTP id 98e67ed59e1d1-2b65fa1b2eamr13540977a91.6.1715459491842; Sat, 11 May 2024 13:31:31 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b62863a5fbsm7170858a91.4.2024.05.11.13.31.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 13:31:31 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 11 May 2024 17:31:20 -0300 Message-ID: <20240511203120.1723-1-jamrial@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240511194656.1576-2-jamrial@gmail.com> References: <20240511194656.1576-2-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2 v2] checkasm/flacdsp: sanitize lpc arguments 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: Fixes signed integer overflows as reported by ubsan. Signed-off-by: James Almer --- Now allowing negative values. tests/checkasm/flacdsp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c index 6561b4ed20..d694c1093b 100644 --- a/tests/checkasm/flacdsp.c +++ b/tests/checkasm/flacdsp.c @@ -21,6 +21,7 @@ #include #include "checkasm.h" #include "libavcodec/flacdsp.h" +#include "libavcodec/mathops.h" #include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" @@ -54,9 +55,10 @@ static void check_decorrelate(uint8_t **ref_dst, uint8_t **ref_src, uint8_t **ne bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / sizeof(int32_t), 8); } -static void check_lpc(int pred_order) +static void check_lpc(int pred_order, int bps) { int qlevel = rnd() % 16; + int coeff_prec = (rnd() % 15) + 1; LOCAL_ALIGNED_16(int32_t, coeffs, [32]); LOCAL_ALIGNED_16(int32_t, dst, [BUF_SIZE]); LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]); @@ -64,10 +66,13 @@ static void check_lpc(int pred_order) declare_func(void, int32_t *, const int[32], int, int, int); + if (bps <= 16) + coeff_prec = av_clip(coeff_prec, 0, 32 - bps - av_log2(pred_order)); + for (int i = 0; i < 32; i++) - coeffs[i] = rnd(); + coeffs[i] = sign_extend(rnd(), coeff_prec); for (int i = 0; i < BUF_SIZE; i++) - dst[i] = rnd(); + dst[i] = sign_extend(rnd(), bps); memcpy(dst0, dst, BUF_SIZE * sizeof (int32_t)); memcpy(dst1, dst, BUF_SIZE * sizeof (int32_t)); @@ -116,10 +121,10 @@ void checkasm_check_flacdsp(void) for (i = 0; i < FF_ARRAY_ELEMS(pred_orders); i++) if (check_func(h.lpc16, "flac_lpc_16_%d", pred_orders[i])) - check_lpc(pred_orders[i]); + check_lpc(pred_orders[i], 16); for (i = 0; i < FF_ARRAY_ELEMS(pred_orders); i++) if (check_func(h.lpc32, "flac_lpc_32_%d", pred_orders[i])) - check_lpc(pred_orders[i]); + check_lpc(pred_orders[i], 32); report("lpc"); } -- 2.45.0 _______________________________________________ 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".