Re: [PATCH] drivers/soc: Remove all strcpy() uses in favor of strscpy()

From: Len Baker
Date: Sat Jul 31 2021 - 10:54:23 EST


Hi,

On Wed, Jul 28, 2021 at 10:36:09AM +0100, Robin Murphy wrote:
> On 2021-07-28 09:36, David Laight wrote:

> > > > - strcpy(pd->name, area->name);
> > > > + strscpy(pd->name, area->name, area_name_size);
> >
> > You can just use memcpy().
>
> Indeed. In fact I'd go as far as saying that it might be worth teaching
> static checkers to recognise patterns that boil down to strscpy(dst, src,
> strlen(src) + 1) and flag them as suspect, because AFAICS that would always
> represent either an unnecessarily elaborate memcpy(), or far worse just an
> obfuscated strcpy().

Ok, I will use the memcpy function instead of strscpy. Thanks for the
feedback.

>
> Robin.

Regards,
Len