Thread (5 messages) 5 messages, 4 authors, 2021-02-28

Re: [PATCH 11/20] hwmon: Manual replacement of the deprecated strlcpy() with return values

flat view

From: Joe Perches <joe@perches.com>
Date: 2021-02-28 11:51:57
Also in: lkml

On Mon, 2021-02-22 at 07:46 -0800, Guenter Roeck wrote:
On 2/22/21 7:12 AM, Romain Perier wrote:
quoted
The strlcpy() reads the entire source buffer first, it is dangerous if
the source buffer lenght is unbounded or possibility non NULL-terminated.
length
quoted
It can lead to linear read overflows, crashes, etc...
Not here. This description is misleading.
quoted
As recommended in the deprecated interfaces [1], it should be replaced
by strscpy.

This commit replaces all calls to strlcpy that handle the return values
by the corresponding strscpy calls with new handling of the return
values (as it is quite different between the two functions).

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy

Signed-off-by: Romain Perier <romain.perier@gmail.com>
This patch just adds pain to injury, as the source 'buffers' are all fixed
strings and their length will never exceed the maximum buffer length.
I really don't see the point of using strscpy() in this situation.
Might as well just use strcpy (I'd still prefer stracpy)

https://lore.kernel.org/lkml/24bb53c57767c1c2a8f266c305a670f7@sk2.org/T/ (local)

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help