Subject: bin/3477: ifconfig set null address if address is not specified.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <koji@math.human.nagoya-u.ac.jp>
List: netbsd-bugs
Date: 04/11/1997 22:59:25
>Number:         3477
>Category:       bin
>Synopsis:       ifconfig set null address if address is not specified.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 11 07:05:00 1997
>Last-Modified:
>Originator:     Koji Imada - je4owb/2
>Organization:
Mathematics Group of Graduate School of Human
	Infomatics, Nagoya University, Japan.
>Release:        970409
>Environment:
	
System: NetBSD bimota 1.2D NetBSD 1.2D (BIMOTA) #4: Thu Apr 10 05:13:05 JST 1997 koji@bimota:/usr/local/work/current/src/sys/arch/i386/compile/BIMOTA i386


>Description:
	ifconfig set null address, if address is not specified. This
	is rare condition but reasonable.
>How-To-Repeat:
	Do 'ifconfig <interface> up' when no address is specified
	yet. Null address(filled with binary 0) is set. This is not
	same with no address.
>Fix:
	apply following patch.

Index: ifconfig.c
===================================================================
RCS file: /mnt2/NetBSD/cvsroot/netbsd/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.1.1.3
diff -c -r1.1.1.3 ifconfig.c
*** ifconfig.c	1997/04/11 08:39:31	1.1.1.3
--- ifconfig.c	1997/04/11 06:06:02
***************
*** 118,124 ****
  char	name[30];
  int	flags, metric, setaddr, setipdst, doalias;
  int	clearaddr, s;
! int	newaddr = 1;
  int	nsellength = 1;
  int	af;
  int	mflag, lflag;
--- 118,124 ----
  char	name[30];
  int	flags, metric, setaddr, setipdst, doalias;
  int	clearaddr, s;
! int	newaddr = -1;
  int	nsellength = 1;
  int	af;
  int	mflag, lflag;
***************
*** 385,391 ****
  				warn("SIOCDIFADDR");
  		}
  	}
! 	if (newaddr) {
  		(void) strncpy(afp->af_addreq, name, sizeof ifr.ifr_name);
  		if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0)
  			warn("SIOCAIFADDR");
--- 385,391 ----
  				warn("SIOCDIFADDR");
  		}
  	}
! 	if (newaddr > 0) {
  		(void) strncpy(afp->af_addreq, name, sizeof ifr.ifr_name);
  		if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0)
  			warn("SIOCAIFADDR");
***************
*** 515,520 ****
--- 515,522 ----
  	 * and the flags may change when the address is set.
  	 */
  	setaddr++;
+ 	if (newaddr == -1)
+ 		newaddr = 1;
  	if (doalias == 0)
  		clearaddr = 1;
  	(*afp->af_getaddr)(addr, (doalias >= 0 ? ADDR : RIDADDR));
>Audit-Trail:
>Unformatted: