From: Borislav Petkov <bp@alien8.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch] ghes_edac: use snprintf() to silence a static checker warning
Date: Tue, 11 Nov 2014 16:55:09 +0000 [thread overview]
Message-ID: <20141111165509.GI31490@pd.tnic> (raw)
In-Reply-To: <20140801082514.GD28869@mwanda>
Did this one get missed? Mauro?
On Fri, Aug 01, 2014 at 11:25:14AM +0300, Dan Carpenter wrote:
> My static checker complains because the "e->location" has up to 256
> characters but we are copying it into the "pvt->detail_location" which
> only has space for 240 characters. That's not counting the surrounding
> text and the "e->other_detail" string which can be over 80 characters
> long.
>
> I am not familiar with this code but presumably it normally works.
> Let's add a limit though for safety.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
> index 8399b4e..b246819 100644
> --- a/drivers/edac/ghes_edac.c
> +++ b/drivers/edac/ghes_edac.c
> @@ -413,8 +413,8 @@ void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
>
> /* Generate the trace event */
> grain_bits = fls_long(e->grain);
> - sprintf(pvt->detail_location, "APEI location: %s %s",
> - e->location, e->other_detail);
> + snprintf(pvt->detail_location, sizeof(pvt->detail_location),
> + "APEI location: %s %s", e->location, e->other_detail);
> trace_mc_event(type, e->msg, e->label, e->error_count,
> mci->mc_idx, e->top_layer, e->mid_layer, e->low_layer,
> PAGES_TO_MiB(e->page_frame_number) | e->offset_in_page,
>
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
next prev parent reply other threads:[~2014-11-11 16:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 8:25 [patch] ghes_edac: use snprintf() to silence a static checker warning Dan Carpenter
2014-11-11 16:55 ` Borislav Petkov [this message]
2014-11-11 17:01 ` Mauro Carvalho Chehab
2014-11-11 17:11 ` Borislav Petkov
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=20141111165509.GI31490@pd.tnic \
--to=bp@alien8.de \
--cc=kernel-janitors@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox