|
Message-ID: <508345C9.2060608@barfooze.de> Date: Sun, 21 Oct 2012 02:46:01 +0200 From: John Spencer <maillist-musl@...fooze.de> To: musl@...ts.openwall.com Subject: Re: [PATCH 4/4] <netinet/ether.h>: Add GNU extensions ether_ntoa_r() and ether_aton_r() On 10/21/2012 02:43 AM, Abdoulaye Walsimou GAYE wrote: > On 10/21/2012 01:53 AM, Rich Felker wrote: >> On Sat, Oct 20, 2012 at 10:15:45PM +0200, Abdoulaye Walsimou Gaye wrote: >>> +struct ether_addr *ether_aton_r(const char *s, struct ether_addr *n) >>> +{ >>> + unsigned int i[6]; >>> + int sz; >>> + >>> + assert(s != NULL); >>> + assert(n != NULL); >>> + >>> + sz = sscanf(s, " %x:%x:%x:%x:%x:%x ", >>> + &i[0], &i[1], &i[2], &i[3], &i[4], &i[5]); >>> + >>> + if (sz == 6) { >>> + n->ether_addr_octet[0] = (unsigned char)i[0]; >>> + n->ether_addr_octet[1] = (unsigned char)i[1]; >>> + n->ether_addr_octet[2] = (unsigned char)i[2]; >>> + n->ether_addr_octet[3] = (unsigned char)i[3]; >>> + n->ether_addr_octet[4] = (unsigned char)i[4]; >>> + n->ether_addr_octet[5] = (unsigned char)i[5]; >>> + return n; >> I think this code could be greatly simplified using %hhx as the format >> instead of %x, but either way it's lacking any error checking and >> accepts lots of inputs that probably should not be accepted. Is this >> an issue? >> >> Rich >> >> > > As I said, the code is almost copied "AS IS" from NetBSD to have > <netinet/ether.h> features, > feel free to amend it. s/amend/reject/
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.