lkml.org 
[lkml]   [2014]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] scsi: csiostor: csio_init.c: Cleaning up missing null-terminate in conjunction with strncpy
Date
If you use kzalloc before strncpy you must copy sizeof -1.
And removed unnecessary magic numbers.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
drivers/scsi/csiostor/csio_init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c
index 1aafc33..d5ea81c 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -532,7 +532,8 @@ static struct csio_hw *csio_hw_alloc(struct pci_dev *pdev)
goto err;

hw->pdev = pdev;
- strncpy(hw->drv_version, CSIO_DRV_VERSION, 32);
+ strncpy(hw->drv_version, CSIO_DRV_VERSION,
+ sizeof(hw->drv_version) - 1);

/* memory pool/DMA pool allocation */
if (csio_resource_alloc(hw))
--
1.7.10.4


\
 
 \ /
  Last update: 2014-07-30 23:41    [W:0.035 / U:0.444 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site