On Mon, Mar 08, 2010 at 11:13:57AM +0000, d binderman wrote: > > > 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)) Thanks for finding this. Looking at the problem, we could simply replace strncpy with strlcpy that guarantees the string termination. I will prepare a patch and send it as fix for 2.6.34. Christof -- To unsubscribe from this list: send the line "unsubscribe linux-s390" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html