[git commit future] ether_aton: reject invalid input

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Tue May 3 15:29:35 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=049aebd7eb798bca4e0fb3c0532328ad9d85cc7c
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future

fixes PR2227

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/inet/ether_addr.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libc/inet/ether_addr.c b/libc/inet/ether_addr.c
index 621c629..9071d71 100644
--- a/libc/inet/ether_addr.c
+++ b/libc/inet/ether_addr.c
@@ -38,10 +38,12 @@ struct ether_addr *ether_aton_r(const char *asc, struct ether_addr *addr)
 
 	for (cnt = 0; cnt < 6; ++cnt) {
 		unsigned char number;
-		char ch;
+		char ch = *asc++;
 
+		if (ch < 0x20)
+			return NULL;
 		/* | 0x20 is cheap tolower(), valid for letters/numbers only */
-		ch = (*asc++) | 0x20;
+		ch |= 0x20;
 		if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
 			return NULL;
 		number = !(ch > '9') ? (ch - '0') : (ch - 'a' + 10);
-- 
1.7.3.4



More information about the uClibc-cvs mailing list