Re: zfcp_aux.c: strncpy problem

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

 



On Mon, 8 Mar 2010 11:13:57 +0000
d binderman <dcb314@xxxxxxxxxxx> 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.

I don't agree with cppcheck:

        token = strsep(&str, ",");
        if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE)
                goto err_out;
        strncpy(busid, token, ZFCP_BUS_ID_SIZE);

strlen(token) < ZFCP_BUS_ID_SIZE which means that the strncpy will
copy the terminating zero byte. The code is correct.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

--
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

[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