[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250706092522.9298-1-pranav.tyagi03@gmail.com>
Date: Sun, 6 Jul 2025 14:55:22 +0530
From: Pranav Tyagi <pranav.tyagi03@...il.com>
To: martin.petersen@...cle.com,
linux-scsi@...r.kernel.org,
target-devel@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: skhan@...uxfoundation.org,
linux-kernel-mentees@...ts.linux.dev,
Pranav Tyagi <pranav.tyagi03@...il.com>
Subject: [PATCH] target/core: replace strncpy with strscpy
strncpy() is deprecated and its use is discouraged. Replace strncpy()
with safer strscpy() as the p_buf buffer should be NUL-terminated, since
it holds human readable debug output strings.
Signed-off-by: Pranav Tyagi <pranav.tyagi03@...il.com>
---
drivers/target/target_core_transport.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 0a76bdfe5528..9c255ed21789 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1112,7 +1112,7 @@ void transport_dump_vpd_proto_id(
}
if (p_buf)
- strncpy(p_buf, buf, p_buf_len);
+ strscpy(p_buf, buf, p_buf_len);
else
pr_debug("%s", buf);
}
@@ -1162,7 +1162,7 @@ int transport_dump_vpd_assoc(
}
if (p_buf)
- strncpy(p_buf, buf, p_buf_len);
+ strscpy(p_buf, buf, p_buf_len);
else
pr_debug("%s", buf);
@@ -1222,7 +1222,7 @@ int transport_dump_vpd_ident_type(
if (p_buf) {
if (p_buf_len < strlen(buf)+1)
return -EINVAL;
- strncpy(p_buf, buf, p_buf_len);
+ strscpy(p_buf, buf, p_buf_len);
} else {
pr_debug("%s", buf);
}
@@ -1276,7 +1276,7 @@ int transport_dump_vpd_ident(
}
if (p_buf)
- strncpy(p_buf, buf, p_buf_len);
+ strscpy(p_buf, buf, p_buf_len);
else
pr_debug("%s", buf);
--
2.49.0
Powered by blists - more mailing lists