From owner-svn-src-head@FreeBSD.ORG Wed Mar 12 12:27:14 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 26CA4748; Wed, 12 Mar 2014 12:27:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 143A8381; Wed, 12 Mar 2014 12:27:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2CCRDXm083889; Wed, 12 Mar 2014 12:27:13 GMT (envelope-from jmmv@svn.freebsd.org) Received: (from jmmv@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2CCRDre083888; Wed, 12 Mar 2014 12:27:13 GMT (envelope-from jmmv@svn.freebsd.org) Message-Id: <201403121227.s2CCRDre083888@svn.freebsd.org> From: Julio Merino Date: Wed, 12 Mar 2014 12:27:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263090 - head/lib/libc/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Mar 2014 12:27:14 -0000 Author: jmmv Date: Wed Mar 12 12:27:13 2014 New Revision: 263090 URL: http://svnweb.freebsd.org/changeset/base/263090 Log: Make ether_line really report an error when all input is invalid. The previous code failed to return an error condition when the whole input was invalid due to improper handling of the sscanf return value. Actually, this failure was properly being caught by a test in tools/regression/lib/libc/net/test-ether.t but was not noticed because these tests are never run. (On my way to fixing that ;-) The fix applied here resembles the implementation of ether_line in NetBSD modulo the setting of an errno value (which is not documented as an expectation in the manpage anyway). Modified: head/lib/libc/net/ether_addr.c Modified: head/lib/libc/net/ether_addr.c ============================================================================== --- head/lib/libc/net/ether_addr.c Wed Mar 12 11:53:35 2014 (r263089) +++ head/lib/libc/net/ether_addr.c Wed Mar 12 12:27:13 2014 (r263090) @@ -72,11 +72,13 @@ ether_line(const char *l, struct ether_a 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); + } } /*