Re: [PATCH v3] drivers/edac/edac_mc: Remove all strcpy() uses

From: Len Baker
Date: Mon Aug 09 2021 - 12:26:25 EST


Hi,

On Mon, Aug 09, 2021 at 11:51:54AM +0200, Robert Richter wrote:
> On 07.08.21 17:59:57, Len Baker wrote:
>
> > @@ -1113,11 +1115,11 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
> > p = e->label;
> > *p = '\0';
> > } else {
> > - if (p != e->label) {
> > - strcpy(p, OTHER_LABEL);
> > - p += strlen(OTHER_LABEL);
> > - }
> > - strcpy(p, dimm->label);
> > + const char *text = (p != e->label) ? OTHER_LABEL :
> > + dimm->label;
> > +
> > + strscpy(p, text, len);
> > + len -= strlen(p);
>
> The logic looks broken and dimm labels are not properly copied (the
> code should add an " or " separator between labels).

Apologies. My bad.

Regards,
Len

>
> > p += strlen(p);
> > }
> >