diff mbox series

platform/x86: hp-bioscfg: Replace deprecated strncpy() with strscpy()

Message ID 20250225232126.356274-2-thorsten.blum@linux.dev (mailing list archive)
State Accepted, archived
Headers show
Series platform/x86: hp-bioscfg: Replace deprecated strncpy() with strscpy() | expand

Commit Message

Thorsten Blum Feb. 25, 2025, 11:21 p.m. UTC
Since kstrtol() requires a NUL-terminated string as input and strncpy()
is deprecated for NUL-terminated destination buffers, use strscpy()
instead.

Compile-tested only.

Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ilpo Järvinen March 3, 2025, 2:32 p.m. UTC | #1
On Wed, 26 Feb 2025 00:21:27 +0100, Thorsten Blum wrote:

> Since kstrtol() requires a NUL-terminated string as input and strncpy()
> is deprecated for NUL-terminated destination buffers, use strscpy()
> instead.
> 
> Compile-tested only.
> 
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86: hp-bioscfg: Replace deprecated strncpy() with strscpy()
      commit: baa18b6ed4200aff869e78f2650123572b6a9ad6

--
 i.
diff mbox series

Patch

diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
index 0b277b7e37dd..889332ddd5ce 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
@@ -448,7 +448,7 @@  int hp_convert_hexstr_to_str(const char *input, u32 input_len, char **str, int *
 		return -ENOMEM;
 
 	for (i = 0; i < input_len; i += 5) {
-		strncpy(tmp, input + i, strlen(tmp));
+		strscpy(tmp, input + i);
 		if (kstrtol(tmp, 16, &ch) == 0) {
 			// escape char
 			if (ch == '\\' ||