[lkml]   [2022]   [Aug]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PULL REQUEST] i2c-for-5.20-part2
On Sat, Aug 13, 2022 at 8:42 AM Wolfram Sang <> wrote:
> * subsystem-wide move from strlcpy to strscpy


Looking around, we still do have a lot of those 'strlcpy()' users, but
99% of them don't use the return value.

And since 'strlcpy()' is complete and utter garbage exactly *BECAUSE*
of the bad return value (it returns the length of the source string -
but an untrusted and possibly unterminated source string is often the
*problem* in the first place), that would make it fairly easy to
convert the rest.

I see two possibilities:

(a) fix strlcpy() by making it return 'void', and leave all those 99%
of users alone, and convert the (few) cases that actually look at the
return value to strscpy

(b) auto-convert (with a coccinelle script) all the 'strlcpy()' users
that don't care about the return value, and leave a few broken users
of strlcpy around

I think (b) is the simpler thing, but I have no idea how to write a
coccinelle patch that basically does "if return value of strlcpy is
not used, convert the strlcpy to a strscpy".

I'd love to get rid of strlcpy() entirely, since it's such a horribly
badly designed thing.


 \ /
  Last update: 2022-08-13 23:38    [W:0.244 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site