From nobody@FreeBSD.org  Thu Jun 14 17:13:54 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0177D106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 17:13:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [69.147.83.34])
	by mx1.freebsd.org (Postfix) with ESMTP id E23408FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 17:13:53 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EHDrho003059
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 17:13:53 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q5EHDrRB003058;
	Thu, 14 Jun 2012 17:13:53 GMT
	(envelope-from nobody)
Message-Id: <201206141713.q5EHDrRB003058@red.freebsd.org>
Date: Thu, 14 Jun 2012 17:13:53 GMT
From: Alexandr <alter@alter.org.ua>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ether-addr output fixup in ndp
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169075
>Category:       bin
>Synopsis:       ether-addr output fixup in ndp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brueffer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 14 17:20:05 UTC 2012
>Closed-Date:    Mon Jul 02 19:49:43 CEST 2012
>Last-Modified:  Mon Jul  2 17:50:07 UTC 2012
>Originator:     Alexandr
>Release:        7.x
>Organization:
Alfa-inet ISP
>Environment:
FreeBSD homecat.alter.org.ua 7.2-RELEASE-p8 FreeBSD 7.2-RELEASE-p8 #6: Sat Apr 23 12:52:20 EEST 2011     root@homecat.alter.org.ua:/usr/src/sys/i386/compile/CAT_v14c  i386

>Description:
The original version of <i>ndp</i> displays ehternet addresses without leading '0' characters in octets.
For example 00:01:ff:88:0a:0b is displayed as 0:1:ff:88:a:b. It inconvenient both for human reading and
machine parsing. Such behavior appears due to '%x' format modified instead of '%2.2x' inside ether_str() routine.

>How-To-Repeat:
ndp -a
>Fix:
replace %x for %2.2x in ether_str()
http://alter.org.ua/soft/fbsd/ndp/fbsd7-ndp-ether_str.20120614.patch.gz


Patch attached with submission follows:

--- ndp.c	2012-06-14 19:29:24.000000000 +0300
+++ ndp.c	2012-06-14 19:28:58.000000000 +0300
@@ -814,7 +814,7 @@
 
 	if (sdl->sdl_alen) {
 		cp = (u_char *)LLADDR(sdl);
-		snprintf(hbuf, sizeof(hbuf), "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
+		snprintf(hbuf, sizeof(hbuf), "%x:%x:%x:%x:%x:%x",
 		    cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
 	} else
 		snprintf(hbuf, sizeof(hbuf), "(incomplete)");


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: brueffer 
State-Changed-When: Mon Jul 2 14:02:16 CEST 2012 
State-Changed-Why:  



Responsible-Changed-From-To: freebsd-bugs->brueffer 
Responsible-Changed-By: brueffer 
Responsible-Changed-When: Mon Jul 2 14:02:16 CEST 2012 
Responsible-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=169075 
State-Changed-From-To: feedback->open 
State-Changed-By: brueffer 
State-Changed-When: Mon Jul 2 14:33:09 CEST 2012 
State-Changed-Why:  
No feedback required.  This issue is only present in RELENG_7 (and lower 
probably), it works properly in RELENG_8 and newer. 

I'll take a look at what changed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169075 
State-Changed-From-To: open->closed 
State-Changed-By: brueffer 
State-Changed-When: Mon Jul 2 19:48:49 CEST 2012 
State-Changed-Why:  
Fixed, thanks for the report! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169075 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/169075: commit references a PR
Date: Mon,  2 Jul 2012 17:48:29 +0000 (UTC)

 Author: brueffer
 Date: Mon Jul  2 17:48:19 2012
 New Revision: 238007
 URL: http://svn.freebsd.org/changeset/base/238007
 
 Log:
   MFC: r217140
   
   Use ether_ntoa instead of home-grown version.
   
   PR:		169075
   Submitted by:	Alexandr <alter@alter.org.ua>
 
 Modified:
   stable/7/usr.sbin/ndp/ndp.c
 Directory Properties:
   stable/7/usr.sbin/ndp/   (props changed)
 
 Modified: stable/7/usr.sbin/ndp/ndp.c
 ==============================================================================
 --- stable/7/usr.sbin/ndp/ndp.c	Mon Jul  2 17:37:40 2012	(r238006)
 +++ stable/7/usr.sbin/ndp/ndp.c	Mon Jul  2 17:48:19 2012	(r238007)
 @@ -148,7 +148,6 @@ static void getdefif __P((void));
  static void setdefif __P((char *));
  #endif
  static char *sec2str __P((time_t));
 -static char *ether_str __P((struct sockaddr_dl *));
  static void ts_print __P((const struct timeval *));
  
  #ifdef ICMPV6CTL_ND6_DRLIST
 @@ -806,17 +805,14 @@ getnbrinfo(addr, ifindex, warning)
  }
  
  static char *
 -ether_str(sdl)
 -	struct sockaddr_dl *sdl;
 +ether_str(struct sockaddr_dl *sdl)
  {
  	static char hbuf[NI_MAXHOST];
 -	u_char *cp;
  
 -	if (sdl->sdl_alen) {
 -		cp = (u_char *)LLADDR(sdl);
 -		snprintf(hbuf, sizeof(hbuf), "%x:%x:%x:%x:%x:%x",
 -		    cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
 -	} else
 +	if (sdl->sdl_alen > 0)
 +		strlcpy(hbuf, ether_ntoa((struct ether_addr *)LLADDR(sdl)),
 +		    sizeof(hbuf));
 +	else
  		snprintf(hbuf, sizeof(hbuf), "(incomplete)");
  
  	return(hbuf);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
