* [patch] ghes_edac: use snprintf() to silence a static checker warning
@ 2014-08-01 8:25 Dan Carpenter
2014-11-11 16:55 ` Borislav Petkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-08-01 8:25 UTC (permalink / raw)
To: kernel-janitors
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,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ghes_edac: use snprintf() to silence a static checker warning
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
2014-11-11 17:01 ` Mauro Carvalho Chehab
2014-11-11 17:11 ` Borislav Petkov
2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2014-11-11 16:55 UTC (permalink / raw)
To: kernel-janitors
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.
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] ghes_edac: use snprintf() to silence a static checker warning
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
@ 2014-11-11 17:01 ` Mauro Carvalho Chehab
2014-11-11 17:11 ` Borislav Petkov
2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2014-11-11 17:01 UTC (permalink / raw)
To: kernel-janitors
Em Tue, 11 Nov 2014 17:55:09 +0100
Borislav Petkov <bp@alien8.de> escreveu:
> Did this one get missed? Mauro?
Yeah, I missed that, sorry.
I can apply it on my tree, but if you want to apply on yours, feel free
to do it, and add my ack:
Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> 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,
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] ghes_edac: use snprintf() to silence a static checker warning
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
2014-11-11 17:01 ` Mauro Carvalho Chehab
@ 2014-11-11 17:11 ` Borislav Petkov
2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2014-11-11 17:11 UTC (permalink / raw)
To: kernel-janitors
On Tue, Nov 11, 2014 at 03:01:08PM -0200, Mauro Carvalho Chehab wrote:
> Em Tue, 11 Nov 2014 17:55:09 +0100
> Borislav Petkov <bp@alien8.de> escreveu:
>
> > Did this one get missed? Mauro?
>
> Yeah, I missed that, sorry.
>
> I can apply it on my tree, but if you want to apply on yours, feel free
> to do it, and add my ack:
>
> Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Aha, I see :-)
Ok, done.
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-11 17:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2014-11-11 17:01 ` Mauro Carvalho Chehab
2014-11-11 17:11 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox