public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] target/core: replace strncpy with strscpy
@ 2025-07-06  9:25 Pranav Tyagi
  2025-07-10 13:29 ` Pranav Tyagi
  2025-07-25  1:51 ` Martin K. Petersen
  0 siblings, 2 replies; 6+ messages in thread
From: Pranav Tyagi @ 2025-07-06  9:25 UTC (permalink / raw)
  To: martin.petersen, linux-scsi, target-devel, linux-kernel
  Cc: skhan, linux-kernel-mentees, Pranav Tyagi

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@gmail.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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-29  9:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-06  9:25 [PATCH] target/core: replace strncpy with strscpy Pranav Tyagi
2025-07-10 13:29 ` Pranav Tyagi
2025-07-25  1:51 ` Martin K. Petersen
2025-07-25 12:16   ` Pranav Tyagi
2025-07-29  3:09     ` Martin K. Petersen
2025-07-29  9:17       ` Pranav Tyagi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox