[PATCH linux-next] scsi: target: core: use strscpy() is more robust and safer

From: cuijinpeng666
Date: Thu Oct 20 2022 - 01:47:10 EST


From: Jinpeng Cui <cui.jinpeng2@xxxxxxxxxx>

The implementation of strscpy() is more robust and safer.

Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
Signed-off-by: Jinpeng Cui <cui.jinpeng2@xxxxxxxxxx>
---
drivers/target/target_core_device.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index b7f16ee8aa0e..0eec5a3217b9 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -809,10 +809,10 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
xcopy_lun->lun_tpg = &xcopy_pt_tpg;

/* Preload the default INQUIRY const values */
- strlcpy(dev->t10_wwn.vendor, "LIO-ORG", sizeof(dev->t10_wwn.vendor));
- strlcpy(dev->t10_wwn.model, dev->transport->inquiry_prod,
+ strscpy(dev->t10_wwn.vendor, "LIO-ORG", sizeof(dev->t10_wwn.vendor));
+ strscpy(dev->t10_wwn.model, dev->transport->inquiry_prod,
sizeof(dev->t10_wwn.model));
- strlcpy(dev->t10_wwn.revision, dev->transport->inquiry_rev,
+ strscpy(dev->t10_wwn.revision, dev->transport->inquiry_rev,
sizeof(dev->t10_wwn.revision));

return dev;
--
2.25.1