linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: mpt2sas: mpt2sas_base.c:  Cleaning up missing null-terminate after strncpy call
@ 2014-06-04 21:36 Rickard Strandqvist
  2014-06-04 22:01 ` Joe Perches
  2014-06-04 22:28 ` James Bottomley
  0 siblings, 2 replies; 5+ messages in thread
From: Rickard Strandqvist @ 2014-06-04 21:36 UTC (permalink / raw)
  To: Nagalakshmi Nandigama, Sreekanth Reddy
  Cc: Rickard Strandqvist, support, James E.J. Bottomley,
	DL-MPTFusionLinux, linux-scsi, linux-kernel

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@spectrumdigital.se>
---
 drivers/scsi/mpt2sas/mpt2sas_base.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index bde63f7..4c3eceb 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -2097,7 +2097,8 @@ _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER *ioc)
 	u32 bios_version;
 
 	bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion);
-	strncpy(desc, ioc->manu_pg0.ChipName, 16);
+	strncpy(desc, ioc->manu_pg0.ChipName, sizeof(desc));
+	desc[sizeof(desc) - 1] = '\0';
 	printk(MPT2SAS_INFO_FMT "%s: FWVersion(%02d.%02d.%02d.%02d), "
 	   "ChipRevision(0x%02x), BiosVersion(%02d.%02d.%02d.%02d)\n",
 	    ioc->name, desc,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-06 13:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-04 21:36 [PATCH] scsi: mpt2sas: mpt2sas_base.c: Cleaning up missing null-terminate after strncpy call Rickard Strandqvist
2014-06-04 22:01 ` Joe Perches
2014-06-04 22:25   ` Rickard Strandqvist
2014-06-04 22:28 ` James Bottomley
2014-06-06 13:02   ` Rickard Strandqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).