[PATCH 5/6] net: set enetaddr to invalid address when an invalid string is passed

Sascha Hauer s.hauer at pengutronix.de
Wed Feb 15 03:04:03 EST 2012


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 net/net.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/net.c b/net/net.c
index 26ba44e..2752884 100644
--- a/net/net.c
+++ b/net/net.c
@@ -166,8 +166,10 @@ int string_to_ethaddr(const char *str, char *enetaddr)
 	int reg;
 	char *e;
 
-        if (!str || strlen(str) != 17)
-                return -1;
+        if (!str || strlen(str) != 17) {
+		memset(enetaddr, 0, 6);
+		return -1;
+	}
 
         if (str[2] != ':' || str[5] != ':' || str[8] != ':' ||
                         str[11] != ':' || str[14] != ':')
-- 
1.7.9




More information about the barebox mailing list