Subject: ifconfig bug
To: None <netbsd-bugs@sun-lamp.cs.berkeley.edu>
From: Frank van der Linden <vdlinden@fwi.uva.nl>
List: netbsd-bugs
Date: 01/20/1994 01:06:00
G'day,

ifconfig dumps core when you have a keyword that requires an argument
last on the command line, for example: 'ifconfig le0 inet xx.xx.xx.xx broadcast'
It doesn't check if the required argument is actually present. Here's a fix
(which also clarifies another error message a bit):

*** ifconfig.c.orig	Fri Dec 10 20:15:06 1993
--- ifconfig.c	Fri Dec 10 18:52:49 1993
***************
*** 261,266 ****
--- 261,272 ----
  			p++;	/* got src, do dst */
  		if (p->c_func) {
  			if (p->c_parameter == NEXTARG) {
+ 				if (argv[1] == NULL) {
+ 					fprintf(stderr,
+ 					  "ifconfig: '%s' requires argument.\n",
+ 					  p->c_name);
+ 					exit(1);
+ 				}
  				(*p->c_func)(argv[1]);
  				argc--, argv++;
  			} else
***************
*** 668,674 ****
  	else if (np = getnetbyname(s))
  		sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY);
  	else {
! 		fprintf(stderr, "%s: bad value\n", s);
  		exit(1);
  	}
  }
--- 674,680 ----
  	else if (np = getnetbyname(s))
  		sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY);
  	else {
! 		fprintf(stderr, "ifconfig: %s: bad value\n", s);
  		exit(1);
  	}
  }

Also, I noticed that specifying a broadcast address with a point-point
link overwrites the address of the opposite site on the link, i.e.
'ifconfig sl0 inet addr1 addr2 broadcast badrr' configures sl0 to
use a point-point link with addr1 on one side, and baddr on the other.
The addresses are stored in the same variable (or rather, same index
in an array), so that's why they mix eachother up. What also strikes
me as odd, is that ifconfig uses the 'ifaliasreq' structure to modify
the network interface (in the SIOxxx ioctl calls), which seems inappropriate
to me.

- Frank

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