From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2164 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 4/4] : Add GNU extensions ether_ntoa_r() and ether_aton_r() Date: Sat, 20 Oct 2012 19:53:13 -0400 Message-ID: <20121020235313.GV254@brightrain.aerifal.cx> References: <1350764145-10305-1-git-send-email-awg@embtoolkit.org> <1350764145-10305-5-git-send-email-awg@embtoolkit.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1350777715 23027 80.91.229.3 (21 Oct 2012 00:01:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Oct 2012 00:01:55 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2165-gllmg-musl=m.gmane.org@lists.openwall.com Sun Oct 21 02:02:03 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TPizT-0003zt-5b for gllmg-musl@plane.gmane.org; Sun, 21 Oct 2012 02:02:03 +0200 Original-Received: (qmail 10015 invoked by uid 550); 21 Oct 2012 00:01:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 10007 invoked from network); 21 Oct 2012 00:01:55 -0000 Content-Disposition: inline In-Reply-To: <1350764145-10305-5-git-send-email-awg@embtoolkit.org> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2164 Archived-At: 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