Re: [PATCH] staging: usbip: stub_main.c: Cleaning up missing null-terminate after strncpy call

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

 



2014-06-11 7:45 GMT+02:00 Dan Carpenter <dan.carpenter@xxxxxxxxxx>:
> On Tue, Jun 10, 2014 at 10:48:35PM +0200, Rickard Strandqvist wrote:
>> Hi
>>
>> True!
>> Sorry  :-(
>>
>> But then one would either operate strcpy outright.
>>
>> Or use strlcpy then the code would be:
>>
>>     /* strlcpy() handles not include \0 */
>>     len = strlcpy(busid, buf + 4, BUSID_SIZE);
>>
>>     /* busid needs to include \0 termination */
>>     if (!(len < BUSID_SIZE))
>
> I don't like this condition.  Just say (len >= BUSID_SIZE).  The
> comments here are obvious and could be left out.
>
>>         return -EINVAL;
>
> I don't have strong feelings about a cleanup patch.  But I think that
> cppcheck is not being very sofisticated here with the NUL termination
> warning so we should not go out of our way to try to silence the
> warning.
>
> regards,
> dan carpenter
>


Hi Dan

I agree that you should not do patches just to silence a static control program.

Concerning (len >= BUSID_SIZE) I agree! But I usually try to change as
little as possible in the patches I do. But perhaps I should not think
that way.



Kind regards
Rickard Strandqvist
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux