|
Message-ID: <20121020235313.GV254@brightrain.aerifal.cx> Date: Sat, 20 Oct 2012 19:53:13 -0400 From: Rich Felker <dalias@...ifal.cx> To: musl@...ts.openwall.com Subject: Re: [PATCH 4/4] <netinet/ether.h>: Add GNU extensions ether_ntoa_r() and ether_aton_r() 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
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.