RE: [PATCH v4] EDAC/mc: Prefer strscpy over strcpy

From: David Laight
Date: Wed Aug 25 2021 - 04:48:35 EST


From: Borislav Petkov
> Sent: 24 August 2021 19:26
..
> so looking at the code, we're merrily decrementing len but nothing's
> checking whether len can become 0. Because if it does, strscpy() will
> do:
>
> if (count == 0 || WARN_ON_ONCE(count > INT_MAX))
> return -E2BIG;

That -E2BIG is going to break something.
It means that you always have to do an error check whenever
you use the return value of strscpy().

Anything that does:
offset += strscpy(...)
is broken.

It really wasn't a good idea for reporting 'truncated'.

David

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