zfcp_aux.c: strncpy problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hello there,

I just ran the sourceforge tool cppcheck over the source code of the
new Linux kernel 2.6.33

It said

Checking ./drivers/s390/scsi/zfcp_aux.c...
[./drivers/s390/scsi/zfcp_aux.c:139]: (style) After a strncpy() the buffer should be zero-terminated

The source code is

        strncpy(busid, token, ZFCP_BUS_ID_SIZE);

I checked the source code and I agree with cppcheck.
Proposed patch file attached.


Regards

David Binderman

 		 	   		  
_________________________________________________________________
Do you have a story that started on Hotmail? Tell us now
http://clk.atdmt.com/UKM/go/195013117/direct/01/
Signed-off-by: David Binderman <dcb314@xxxxxxxxxxx>

--- drivers/s390/scsi/zfcp_aux.c.sav	2010-03-08 11:08:25.000000000 +0000
+++ drivers/s390/scsi/zfcp_aux.c	2010-03-08 11:08:54.000000000 +0000
@@ -137,6 +137,7 @@ static void __init zfcp_init_device_setu
 	if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE)
 		goto err_out;
 	strncpy(busid, token, ZFCP_BUS_ID_SIZE);
+	busid[ZFCP_BUS_ID_SIZE - 1] = 0;
 
 	token = strsep(&str, ",");
 	if (!token || strict_strtoull(token, 0, (unsigned long long *) &wwpn))

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux