All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>,
	"Noralf Trønnes" <noralf@tronnes.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: fbtft: fix out of bound access
Date: Thu, 4 Jun 2015 15:36:31 +0300	[thread overview]
Message-ID: <20150604123631.GE28762@mwanda> (raw)
In-Reply-To: <1433418121-9434-1-git-send-email-sudipm.mukherjee@gmail.com>

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


  parent reply	other threads:[~2015-06-04 12:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-06-04 12:47   ` Sudip Mukherjee

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=20150604123631.GE28762@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noralf@tronnes.org \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=thomas.petazzoni@free-electrons.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.