All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Len Baker <len.baker@gmx.com>
Cc: Borislav Petkov <bp@alien8.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Tony Luck <tony.luck@intel.com>,
	James Morse <james.morse@arm.com>,
	Robert Richter <rric@kernel.org>,
	David Laight <David.Laight@aculab.com>,
	Kees Cook <keescook@chromium.org>,
	linux-hardening@vger.kernel.org, linux-edac@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6] EDAC/mc: Prefer strscpy or scnprintf over strcpy
Date: Fri, 03 Sep 2021 10:03:18 -0700	[thread overview]
Message-ID: <3a035a3ec4571a622ce640e042f9a119@perches.com> (raw)
In-Reply-To: <20210903150539.7282-1-len.baker@gmx.com>

On 2021-09-03 08:05, Len Baker wrote:
> strcpy() performs no bounds checking on the destination buffer. 
> len.baker@gmx.com/

[]

> @@ -1113,12 +1115,9 @@ 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);
> -			p += strlen(p);
> +			n += scnprintf(e->label + n, sizeof(e->label) - n,
> +				       "%s%s", prefix, dimm->label);
> +			prefix = OTHER_LABEL;

OTHER_LABEL is a define specific to this module

IMO: Used once text macros are just obfuscating and should be removed.

  reply	other threads:[~2021-09-03 17:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03 15:05 [PATCH v6] EDAC/mc: Prefer strscpy or scnprintf over strcpy Len Baker
2021-09-03 17:03 ` Joe Perches [this message]
2021-09-04 11:23   ` Len Baker
2021-09-04 11:36     ` Borislav Petkov
2021-09-04 13:22       ` Len Baker
2021-09-13  8:59 ` [PATCH] EDAC/mc: Prefer strscpy or scnprintf over strcpy, sprintf and snprintf Robert Richter
2021-09-15 11:58   ` Borislav Petkov
2021-09-18  9:17   ` Len Baker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3a035a3ec4571a622ce640e042f9a119@perches.com \
    --to=joe@perches.com \
    --cc=David.Laight@aculab.com \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=keescook@chromium.org \
    --cc=len.baker@gmx.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=rric@kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.