And as I understand it, it is fine to replace strncpy to strlcpy here.
But if any of this code do not want a null terminated, or want to have the whole rest of size filled with null characters.
If that is the case this is not a good patch.
Rickard Strandqvist (1):
scsi: ibmvscsi: ibmvfc.c: Cleaning up missing null-terminate in conjunction with
strncpy
drivers/scsi/ibmvscsi/ibmvfc.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
--
1.7.10.4
Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
Signed-off-by: Rickard Strandqvist <[email protected]>
---
drivers/scsi/ibmvscsi/ibmvfc.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 8dd4768..56c26ef 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1149,7 +1149,8 @@ static void ibmvfc_gather_partition_info(struct ibmvfc_host *vhost)
name = of_get_property(rootdn, "ibm,partition-name", NULL);
if (name)
- strncpy(vhost->partition_name, name, sizeof(vhost->partition_name));
+ strlcpy(vhost->partition_name, name,
+ sizeof(vhost->partition_name));
num = of_get_property(rootdn, "ibm,partition-no", NULL);
if (num)
vhost->partition_number = *num;
@@ -1186,13 +1187,14 @@ static void ibmvfc_set_login_info(struct ibmvfc_host *vhost)
login_info->capabilities = IBMVFC_CAN_MIGRATE;
login_info->async.va = vhost->async_crq.msg_token;
login_info->async.len = vhost->async_crq.size * sizeof(*vhost->async_crq.msgs);
- strncpy(login_info->partition_name, vhost->partition_name, IBMVFC_MAX_NAME);
- strncpy(login_info->device_name,
+ strlcpy(login_info->partition_name, vhost->partition_name,
+ IBMVFC_MAX_NAME);
+ strlcpy(login_info->device_name,
dev_name(&vhost->host->shost_gendev), IBMVFC_MAX_NAME);
location = of_get_property(of_node, "ibm,loc-code", NULL);
location = location ? location : dev_name(vhost->dev);
- strncpy(login_info->drc_name, location, IBMVFC_MAX_NAME);
+ strlcpy(login_info->drc_name, location, IBMVFC_MAX_NAME);
}
/**
--
1.7.10.4