[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1401917675-3044-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Date: Wed, 4 Jun 2014 23:34:35 +0200
From: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To: Robert Jennings <rcj@...ux.vnet.ibm.com>,
"James E.J. Bottomley" <JBottomley@...allels.com>
Cc: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>,
Grant Likely <grant.likely@...aro.org>,
Rob Herring <robh+dt@...nel.org>, linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Subject: [PATCH] scsi: ibmvscsi: ibmvscsi.c: Cleaning up missing null-terminate after strncpy call
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@...ctrumdigital.se>
---
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists