* [PATCH] staging: fbtft: fix out of bound access
@ 2015-06-04 11:42 Sudip Mukherjee
2015-06-04 12:12 ` Joe Perches
2015-06-04 12:36 ` Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2015-06-04 11:42 UTC (permalink / raw)
To: Thomas Petazzoni, Noralf Trønnes, Greg Kroah-Hartman
Cc: devel, linux-kernel, Sudip Mukherjee
size of str is 16, but in snprintf the size was mentioned as 128.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
drivers/staging/fbtft/fbtft-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index ce64521..0af84b5 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -1096,7 +1096,7 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
/* make debug message */
msg[0] = '\0';
for (j = 0; j < i; j++) {
- snprintf(str, 128, " %02X", buf[j]);
+ snprintf(str, 16, " %02X", buf[j]);
strcat(msg, str);
}
fbtft_par_dbg(DEBUG_INIT_DISPLAY, par,
--
1.8.1.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: fbtft: fix out of bound access
2015-06-04 11:42 [PATCH] staging: fbtft: fix out of bound access Sudip Mukherjee
@ 2015-06-04 12:12 ` Joe Perches
2015-06-04 12:21 ` Sudip Mukherjee
2015-06-04 12:36 ` Dan Carpenter
1 sibling, 1 reply; 5+ messages in thread
From: Joe Perches @ 2015-06-04 12:12 UTC (permalink / raw)
To: Sudip Mukherjee
Cc: Thomas Petazzoni, Noralf Trønnes, Greg Kroah-Hartman, devel,
linux-kernel
On Thu, 2015-06-04 at 17:12 +0530, Sudip Mukherjee wrote:
> size of str is 16, but in snprintf the size was mentioned as 128.
[]
> diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
[]
> @@ -1096,7 +1096,7 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
> /* make debug message */
> msg[0] = '\0';
> for (j = 0; j < i; j++) {
> - snprintf(str, 128, " %02X", buf[j]);
> + snprintf(str, 16, " %02X", buf[j]);
using sizeof(str) is probably more robust
msg isn't big enough to hold the maximum possible output.
If this is really useful, and I rather doubt it is,
it'd probably be better to use a loop to output
multiple lines, one for each register.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: fbtft: fix out of bound access
2015-06-04 12:12 ` Joe Perches
@ 2015-06-04 12:21 ` Sudip Mukherjee
0 siblings, 0 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2015-06-04 12:21 UTC (permalink / raw)
To: Joe Perches
Cc: Thomas Petazzoni, Noralf Trønnes, Greg Kroah-Hartman, devel,
linux-kernel
On Thu, Jun 04, 2015 at 05:12:23AM -0700, Joe Perches wrote:
> On Thu, 2015-06-04 at 17:12 +0530, Sudip Mukherjee wrote:
> > size of str is 16, but in snprintf the size was mentioned as 128.
> []
> > diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
> []
> > @@ -1096,7 +1096,7 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
> > /* make debug message */
> > msg[0] = '\0';
> > for (j = 0; j < i; j++) {
> > - snprintf(str, 128, " %02X", buf[j]);
> > + snprintf(str, 16, " %02X", buf[j]);
>
> using sizeof(str) is probably more robust
>
> msg isn't big enough to hold the maximum possible output.
yes, it will not hold. i didn't notice msg size.
>
> If this is really useful, and I rather doubt it is,
> it'd probably be better to use a loop to output
> multiple lines, one for each register.
I will send in a v2 doing this.
regards
sudip
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: fbtft: fix out of bound access
2015-06-04 11:42 [PATCH] staging: fbtft: fix out of bound access Sudip Mukherjee
2015-06-04 12:12 ` Joe Perches
@ 2015-06-04 12:36 ` Dan Carpenter
2015-06-04 12:47 ` Sudip Mukherjee
1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2015-06-04 12:36 UTC (permalink / raw)
To: Sudip Mukherjee
Cc: Thomas Petazzoni, Noralf Trønnes, Greg Kroah-Hartman, devel,
linux-kernel
On Thu, Jun 04, 2015 at 05:12:01PM +0530, Sudip Mukherjee wrote:
> size of str is 16, but in snprintf the size was mentioned as 128.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
> drivers/staging/fbtft/fbtft-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
> index ce64521..0af84b5 100644
> --- a/drivers/staging/fbtft/fbtft-core.c
> +++ b/drivers/staging/fbtft/fbtft-core.c
> @@ -1096,7 +1096,7 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
> /* make debug message */
> msg[0] = '\0';
> for (j = 0; j < i; j++) {
> - snprintf(str, 128, " %02X", buf[j]);
> + snprintf(str, 16, " %02X", buf[j]);
Good eye. How did you find this?
The good news is buf[j] is <= 0xFFFF so it won't actually overflow. Who
knows why it is zero padded 2 spaces... But use sizeof(str) instead of
16.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: fbtft: fix out of bound access
2015-06-04 12:36 ` Dan Carpenter
@ 2015-06-04 12:47 ` Sudip Mukherjee
0 siblings, 0 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2015-06-04 12:47 UTC (permalink / raw)
To: Dan Carpenter
Cc: Thomas Petazzoni, Noralf Trønnes, Greg Kroah-Hartman, devel,
linux-kernel
On Thu, Jun 04, 2015 at 03:36:31PM +0300, Dan Carpenter wrote:
> On Thu, Jun 04, 2015 at 05:12:01PM +0530, Sudip Mukherjee wrote:
> > size of str is 16, but in snprintf the size was mentioned as 128.
> >
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > ---
<snip>
> Good eye. How did you find this?
:) not me. cppcheck.
>
> The good news is buf[j] is <= 0xFFFF so it won't actually overflow. Who
> knows why it is zero padded 2 spaces... But use sizeof(str) instead of
> 16.
but my v2 will remove the use of msg and str.
regards
sudip
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-04 12:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-04 11:42 [PATCH] staging: fbtft: fix out of bound access Sudip Mukherjee
2015-06-04 12:12 ` Joe Perches
2015-06-04 12:21 ` Sudip Mukherjee
2015-06-04 12:36 ` Dan Carpenter
2015-06-04 12:47 ` Sudip Mukherjee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox