From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2171 Path: news.gmane.org!not-for-mail From: Abdoulaye Walsimou GAYE Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 4/4] : Add GNU extensions ether_ntoa_r() and ether_aton_r() Date: Sun, 21 Oct 2012 02:43:57 +0200 Message-ID: <5083454D.7010403@embtoolkit.org> References: <1350764145-10305-1-git-send-email-awg@embtoolkit.org> <1350764145-10305-5-git-send-email-awg@embtoolkit.org> <20121020235313.GV254@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1350780246 6450 80.91.229.3 (21 Oct 2012 00:44:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Oct 2012 00:44:06 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2172-gllmg-musl=m.gmane.org@lists.openwall.com Sun Oct 21 02:44:14 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 1TPjeH-0007Ek-S2 for gllmg-musl@plane.gmane.org; Sun, 21 Oct 2012 02:44:14 +0200 Original-Received: (qmail 30013 invoked by uid 550); 21 Oct 2012 00:44:06 -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 30005 invoked from network); 21 Oct 2012 00:44:06 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 In-Reply-To: <20121020235313.GV254@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:2171 Archived-At: 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 features, feel free to amend it. cheers, AWG