Patchwork Fix overflow of name in struct net_device, replaced sprintf with snprintf.

login
register
mail settings
Submitter Sasikanth V
Date March 15, 2011, 8 p.m.
Message ID <1300219208-2708-1-git-send-email-sasikanth.v19@gmail.com>
Download mbox | patch
Permalink /patch/87071/
State Rejected
Delegated to: David Miller
Headers show

Comments

Sasikanth V - March 15, 2011, 8 p.m.
Signed-off-by: Sasikanth V <sasikanth.v19@gmail.com>
---
 net/core/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
stephen hemminger - March 15, 2011, 9:48 p.m.
On Wed, 16 Mar 2011 01:30:08 +0530
Sasikanth V <sasikanth.v19@gmail.com> wrote:

> 
> Signed-off-by: Sasikanth V <sasikanth.v19@gmail.com>
> ---
>  net/core/dev.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 6561021..a74efa9 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -539,7 +539,7 @@ unsigned long netdev_boot_base(const char *prefix, int unit)
>  	char name[IFNAMSIZ];
>  	int i;
>  
> -	sprintf(name, "%s%d", prefix, unit);
> +	snprintf(name, IFNAMSIZ, "%s%d", prefix, unit);
>  
>  	/*
>  	 * If device already registered then return base of 1

that code is only called with a really small values "eth" and "tr" so
it is really not necessary. The whole drivers/net/Space.c code is totally
legacy and should eventually be eliminated anyway.

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index 6561021..a74efa9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -539,7 +539,7 @@  unsigned long netdev_boot_base(const char *prefix, int unit)
 	char name[IFNAMSIZ];
 	int i;
 
-	sprintf(name, "%s%d", prefix, unit);
+	snprintf(name, IFNAMSIZ, "%s%d", prefix, unit);
 
 	/*
 	 * If device already registered then return base of 1