scsi: target: replace strncpy() with strscpy()
Subsystems (2)
PATCH 1/1 scsi: target: replace strncpy() with strscpy()
Replace strncpy function calls to more reliable function like strscpy for safer null termination.
Earlier code had some strncpy functions still in use which could be replaced with strscpy() since it always NULL terminates the destina -tion buffer also it does not waste cycles padding with zeros unlike strncpy(). In regard to this convert strncpy to strscpy to prevent accidental buffer overreads and ensure null termination of destination buffer.
No functional changes intended.
Signed-off-by Shi Hao <[email protected]>
--- drivers/target/target_core_transport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/target/target_core_transport.c +4 -4
@@ -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.51.0