* [PATCH] Staging: dgnc: Replace snprintf instead of sprintf
@ 2015-04-24 11:22 DHANAPAL, GNANACHANDRAN (G.)
2015-04-24 11:25 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: DHANAPAL, GNANACHANDRAN (G.) @ 2015-04-24 11:22 UTC (permalink / raw)
To: gregkh@linuxfoundation.org
Cc: lidza.louina@gmail.com, markh@compro.net,
driverdev-devel@linuxdriverproject.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Babu, Viswanathan (V.), gnanachandran@gmail.com
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);
spin_unlock_irqrestore(&dgnc_global_lock, flags);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Staging: dgnc: Replace snprintf instead of sprintf
2015-04-24 11:22 [PATCH] Staging: dgnc: Replace snprintf instead of sprintf DHANAPAL, GNANACHANDRAN (G.)
@ 2015-04-24 11:25 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2015-04-24 11:25 UTC (permalink / raw)
To: DHANAPAL, GNANACHANDRAN (G.)
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
Babu, Viswanathan (V.), lidza.louina@gmail.com,
driverdev-devel@linuxdriverproject.org,
linux-kernel@vger.kernel.org
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-24 11:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-24 11:22 [PATCH] Staging: dgnc: Replace snprintf instead of sprintf DHANAPAL, GNANACHANDRAN (G.)
2015-04-24 11:25 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox