Re: [PATCH] misc: ti-st: st_kim.c: Cleaning up missing null-terminate after strncpy call

From: Rickard Strandqvist
Date: Mon Aug 11 2014 - 15:46:23 EST


2014-08-11 11:14 GMT+02:00 Wolfram Sang <wsa@xxxxxxxxxxxxx>:
>
>> > strncpy(kim_data->dev_name, buf, count);
>> > + kim_data->dev_name[count - 1] = '\n';
>>
>> Of course this does not add termination, but adds a newline at the end of the buffer? Huh?
>
> strlcpy?
>

Hi Wolfram

Sure, strlcpy is preferable in many ways if we only can guarantee that
it is safe.
I have seldom been so much criticism when I start switching to
strlcpy, although much of it was justified :)
Even Linus was getting into the debate. See more:

https://plus.google.com/111049168280159033135/posts/1amLbuhWbh5


I do this only when I'm sure it will not cause any other problems.
But if you or anyone else can guarantee that in this case, so I'd make
a new patch.


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