From 91340701c35104ff7596b960df06324e4b09cb67 Mon Sep 17 00:00:00 2001 From: jmmv Date: Thu, 17 Apr 2014 11:49:19 +0000 Subject: [PATCH] MFC r263090: Make ether_line really report an error when all input is invalid. git-svn-id: svn://svn.freebsd.org/base/stable/10@264592 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- lib/libc/net/ether_addr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/libc/net/ether_addr.c b/lib/libc/net/ether_addr.c index 5d72606af..19d10ac5e 100644 --- a/lib/libc/net/ether_addr.c +++ b/lib/libc/net/ether_addr.c @@ -72,11 +72,13 @@ ether_line(const char *l, struct ether_addr *e, char *hostname) i = sscanf(l, "%x:%x:%x:%x:%x:%x %s", &o[0], &o[1], &o[2], &o[3], &o[4], &o[5], hostname); - if (i != 7) - return (i); - for (i=0; i<6; i++) - e->octet[i] = o[i]; - return (0); + if (i == 7) { + for (i = 0; i < 6; i++) + e->octet[i] = o[i]; + return (0); + } else { + return (-1); + } } /* -- 2.45.0