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

Romain Perier
2021-02-23T09:44:21Z

[-- Attachment #1: Type: text/plain, Size: 1625 bytes --]

Le lun. 22 févr. 2021 à 16:46, Guenter Roeck <linux@roeck-us.net> a écrit :

> On 2/22/21 7:12 AM, Romain Perier wrote:
> > The strlcpy() reads the entire source buffer first, it is dangerous if
> > the source buffer lenght is unbounded or possibility non NULL-terminated.
>
> length
>
> > It can lead to linear read overflows, crashes, etc...
> >
> Not here. This description is misleading.
>
> > 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.
>
>
Hi,

No, no insult or offense at all here (sorry if you understood like this, it
is not my intention ^^), it is just a general description of what the usage
of strlcpy might cause (the description is not specific to your code). The
initial idea was to globally replace all occurrences of the old by the new
functions (the old being deprecated for a reason), however, if some
maintainers disagree or don't think that their drivers are affected, no
problem we can exclude these from the patches series.

Romain

[-- Attachment #2: Type: text/html, Size: 2256 bytes --]