lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230831073432.1712904-1-suhui@nfschina.com>
Date:   Thu, 31 Aug 2023 15:34:32 +0800
From:   Su Hui <suhui@...china.com>
To:     robert.moore@...el.com, rafael.j.wysocki@...el.com, lenb@...nel.org
Cc:     linux-acpi@...r.kernel.org, acpica-devel@...ts.linuxfoundation.org,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Su Hui <suhui@...china.com>
Subject: [PATCH 1/2] ACPICA: Use strscpy to replace strncpy

With gcc and W=1 option to compile kernel, warning happens:

inlined from ‘acpi_tb_find_table’ at drivers/acpi/acpica/tbfind.c:60:2:
include/linux/fortify-string.h:68:30: error: ‘__builtin_strncpy’ specified
bound 6 equals destination size [-Werror=stringop-truncation]

Use strscpy to avoid this warning and is safer.

Signed-off-by: Su Hui <suhui@...china.com>
---
 drivers/acpi/acpica/tbfind.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 1c1b2e284bd9..5536d1755188 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -57,8 +57,8 @@ acpi_tb_find_table(char *signature,
 
 	memset(&header, 0, sizeof(struct acpi_table_header));
 	ACPI_COPY_NAMESEG(header.signature, signature);
-	strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
-	strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
+	strscpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
+	strscpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
 
 	/* Search for the table */
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ