Subject: bin/39: xntp doesn't properly bind interfaces
To: None <gnats-admin>
From: None <tholo@SigmaSoft.COM>
List: netbsd-bugs
Date: 12/10/1993 10:05:04
>Number:         39
>Category:       bin
>Synopsis:       xntp tries to locate all interfaces, but structure changed
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 10 10:05:02 1993
>Originator:     Thorsten Lockert
>Organization:
Thorsten Lockert  | postmaster@bbb.no   |
Postbox 435       | hostmaster@bbb.no   |  Universe, n.:
N-5001 Bergen     | tholo@bbb.no        |          The problem.
Norway            | tholo@sigmasoft.com |
>Release:        NetBSD-current
>Environment:
System: NetBSD gandalf.bbb.no 0.9a GANDALF#8 i386
>Description:
xntp uses old code to get a list of all interfaces on the system in order
to bind each one seperately.  This is fixed in newer versions of xntp,
but I've put in a patch that duplicates the behavious of newer versions
>How-To-Repeat:
If you look at the output from 'netstat -a', you will find that it has
only bound the wildcard port '*.ntp', and not interface-specific ports.
The code also ignores any packets received on the wildcard port, and thus
refuse to operate.

After the fix has been installed, it will properly bind the interface
specific ports as well.
>Fix:
*** ntp_io.c.orig	Sun Nov  7 12:40:20 1993
--- ntp_io.c	Tue Dec  7 10:13:40 1993
***************
*** 191,197 ****
  	char	buf[1024];
  	struct	ifconf	ifc;
  	struct	ifreq	ifreq, *ifr;
! 	int n, i, j, vs;
  	struct sockaddr_in resmask;
  	int open_socket();
  	extern void restrict();
--- 191,197 ----
  	char	buf[1024];
  	struct	ifconf	ifc;
  	struct	ifreq	ifreq, *ifr;
! 	int size, n, i, j, vs;
  	struct sockaddr_in resmask;
  	int open_socket();
  	extern void restrict();
***************
*** 221,230 ****
  		syslog(LOG_ERR, "get interface configuration: %m");
  		exit(1);
  	}
! 	n = ifc.ifc_len/sizeof(struct ifreq);
  
  	i = 1;
! 	for (ifr = ifc.ifc_req; n > 0; n--, ifr++) {
  		if (ifr->ifr_addr.sa_family != AF_INET)
  			continue;
  		ifreq = *ifr;
--- 221,239 ----
  		syslog(LOG_ERR, "get interface configuration: %m");
  		exit(1);
  	}
! 	n = ifc.ifc_len;
  
  	i = 1;
! 	for (ifr = ifc.ifc_req; n > 0;
! 	     ifr = (struct ifreq *)((char *)ifr + size)) {
! 		size = sizeof(*ifr);
! #if defined(BSD) && !defined(sun)
! #if BSD >= 199006
! 		if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_addr))
! 			size += ifr->ifr_addr.sa_len - sizeof(struct sockaddr);
! #endif
! #endif
! 		n -= size;
  		if (ifr->ifr_addr.sa_family != AF_INET)
  			continue;
  		ifreq = *ifr;
>Audit-Trail:
>Unformatted:

------------------------------------------------------------------------------