From patchwork Fri Mar 15 10:15:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1912432 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tx0X25TW2z1yX0 for ; Fri, 15 Mar 2024 21:16:17 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rl4bd-0003BB-IG; Fri, 15 Mar 2024 10:16:06 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rl4bU-00039x-Jk for fwts-devel@lists.ubuntu.com; Fri, 15 Mar 2024 10:15:56 +0000 Received: from canonical.com (unknown [106.104.136.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id A02133F5FC for ; Fri, 15 Mar 2024 10:15:55 +0000 (UTC) From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpi: srat: fix the untrusted loop bound warning Date: Fri, 15 Mar 2024 18:15:41 +0800 Message-Id: <20240315101541.118551-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" BugLink: https://bugs.launchpad.net/fwts/+bug/2058008 coverity scan the length is untrust loop bound, which is from tainted_data_downcast fwts_acpi_table_srat, use table->length to avoid this warning, no function impact. CID 323875: (#1 of 1): Untrusted loop bound (TAINTED_SCALAR) 5. tainted_data: Using tainted variable length as a loop boundary. Signed-off-by: Ivan Hu --- src/acpi/srat/srat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/acpi/srat/srat.c b/src/acpi/srat/srat.c index 9558be97..088e7542 100644 --- a/src/acpi/srat/srat.c +++ b/src/acpi/srat/srat.c @@ -408,7 +408,7 @@ static int srat_test1(fwts_framework *fw) const fwts_acpi_table_srat *srat = (const fwts_acpi_table_srat *)table->data; uint8_t *data = (uint8_t *)table->data; bool passed = true; - ssize_t length = (ssize_t)srat->header.length; + ssize_t length = (ssize_t)table->length; fwts_acpi_fixed_value(fw, LOG_LEVEL_MEDIUM, "SRAT", "Revision1", srat->reserved1, 1, &passed);