[PATCH] scsi: ibmvscsi: ibmvscsi.c: Cleaning up missing null-terminate after strncpy call

From: Rickard Strandqvist
Date: Wed Jun 04 2014 - 17:33:45 EST


Added a guaranteed null-terminate after call to strncpy.

This was partly found using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@xxxxxxxxxxxxxxxxxx>
---
drivers/scsi/ibmvscsi/ibmvscsi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index fa76440..e214f9e 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -250,9 +250,11 @@ static void gather_partition_info(void)
}

ppartition_name = of_get_property(rootdn, "ibm,partition-name", NULL);
- if (ppartition_name)
+ if (ppartition_name) {
strncpy(partition_name, ppartition_name,
sizeof(partition_name));
+ partition_name[sizeof(partition_name) - 1] = '\0';
+ }
p_number_ptr = of_get_property(rootdn, "ibm,partition-no", NULL);
if (p_number_ptr)
partition_number = of_read_number(p_number_ptr, 1);
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/