public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: "DHANAPAL, GNANACHANDRAN (G.)" <gdhanapa@visteon.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"Babu, Viswanathan (V.)" <vbabu3@visteon.com>,
	"lidza.louina@gmail.com" <lidza.louina@gmail.com>,
	"driverdev-devel@linuxdriverproject.org" 
	<driverdev-devel@linuxdriverproject.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Staging: dgnc: Replace snprintf instead of sprintf
Date: Fri, 24 Apr 2015 14:25:49 +0300	[thread overview]
Message-ID: <20150424112549.GN14154@mwanda> (raw)
In-Reply-To: <20150424112413.GA13642@visteon-gnana>

On Fri, Apr 24, 2015 at 11:22:24AM +0000, DHANAPAL, GNANACHANDRAN (G.) wrote:
> This patch replaces snprintf instead of sprintf to avoid buffer overflow
> 
> Signed-off-by: Gnanachandran Dhanapal <gdhanapa@visteon.com>
> ---
>  drivers/staging/dgnc/dgnc_mgmt.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
> index b13318a..aa20a66 100644
> --- a/drivers/staging/dgnc/dgnc_mgmt.c
> +++ b/drivers/staging/dgnc/dgnc_mgmt.c
> @@ -116,7 +116,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  		spin_lock_irqsave(&dgnc_global_lock, flags);
>  
>  		ddi.dinfo_nboards = dgnc_NumBoards;
> -		sprintf(ddi.dinfo_version, "%s", DG_PART);
> +		snprintf(ddi.dinfo_version, strlen(DG_PART)+1, "%s", DG_PART);

This change makes no sense.  If the original had memory corruption then
the new code has memory corruption as well.

regards,
dan carpenter


      reply	other threads:[~2015-04-24 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24 11:22 [PATCH] Staging: dgnc: Replace snprintf instead of sprintf DHANAPAL, GNANACHANDRAN (G.)
2015-04-24 11:25 ` Dan Carpenter [this message]

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=20150424112549.GN14154@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gdhanapa@visteon.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lidza.louina@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vbabu3@visteon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox