[PATCH] Fix overflow of name in struct net_device, replaced sprintf with snprintf.

Subsystems: networking [general], the rest

STALE5658d

2 messages, 2 authors, 2011-03-15 · open the first message on its own page

[PATCH] Fix overflow of name in struct net_device, replaced sprintf with snprintf.

From: Sasikanth V <hidden>
Date: 2011-03-15 20:00:19

Signed-off-by: Sasikanth V <redacted>
---
 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
-- 
1.7.3.4

Re: [PATCH] Fix overflow of name in struct net_device, replaced sprintf with snprintf.

From: Stephen Hemminger <hidden>
Date: 2011-03-15 21:48:22

On Wed, 16 Mar 2011 01:30:08 +0530
Sasikanth V [off-list ref] wrote:
quoted hunk
Signed-off-by: Sasikanth V <redacted>
---
 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.


-- 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help