RE: [RFC] string: Allow 2-argument strscpy()

From: David Laight
Date: Thu Feb 01 2024 - 17:30:12 EST


From: Kees Cook
> Sent: 29 January 2024 20:29
>
> Using sizeof(dst) is the overwhelmingly common case for strscpy().
> Instead of requiring this everywhere, allow a 2-argument version to be
> used that will use the sizeof() internally.

You may want to (try to) add a check that the first argument is
actually an array rather than just a pointer.

But the cpp output bloat can get silly and slow the build down.
I guess no one would do:
x = min(strscpy(a, b), strscpy(c, d));
but you can never tell :-)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)