From michaelb@demon.net Mon Dec  6 11:14:03 1999
Return-Path: <michaelb@demon.net>
Received: from internal.mail.demon.net (internal.mail.demon.net [193.195.224.3])
	by hub.freebsd.org (Postfix) with ESMTP id B9903153A9
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  6 Dec 1999 11:14:00 -0800 (PST)
	(envelope-from michaelb@demon.net)
Received: from singsing.eng.demon.net (singsing.eng.demon.net [195.11.55.94])
	by internal.mail.demon.net with ESMTP id QAA17090;
	Mon, 6 Dec 1999 16:32:09 GMT
Received: from michaelb by singsing.eng.demon.net with local (Exim 3.03 #1)
	id 11v135-000E2H-00
	for FreeBSD-gnats-submit@freebsd.org; Mon, 06 Dec 1999 16:31:39 +0000
Message-Id: <E11v135-000E2H-00@singsing.eng.demon.net>
Date: Mon, 06 Dec 1999 16:31:39 +0000
From: Mike Bristow <michaelb@demon.net>
Reply-To: michaelb@demon.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: ifconfig dumps core 
X-Send-Pr-Version: 3.2

>Number:         15318
>Category:       bin
>Synopsis:       ifconfig dumps core
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec  6 11:20:00 PST 1999
>Closed-Date:    Tue Jan 11 04:34:34 PST 2000
>Last-Modified:  Tue Jan 11 04:37:19 PST 2000
>Originator:     Mike Bristow
>Release:        FreeBSD 3.3-STABLE-19991129 i386; FreeBSD 4.0-CURRENT-19991118 i386 ; FreeBSD-3.3-RELEASE i386
>Organization:
Thus PLC
>Environment:

FreeBSD 3.3-RELEASE; FreeBSD-3.3-STABLE; FreeBSD-

>Description:

ifconfig will dump core when run with certain arguments; this is when
the struct afswtch contains a NULL function pointer which gets called.

>How-To-Repeat:

	/sbin/ifconfig foo0 ether 66:c0:4f:60:49:e1
	(with some value of foo that exists on the system)


>Fix:
	
The following patch will fix the core dump by making ifconfig notice a
NULL function pointer and exit.  It applies to FreeBSD-STABLE; I
haven't checked FreeBSD-CURRENT (other than confirming that the
behaviour is identical). 

--- /usr/src/sbin/ifconfig/ifconfig.c.orig	Thu Sep  2 16:30:32 1999
+++ /usr/src/sbin/ifconfig/ifconfig.c	Mon Dec  6 16:06:32 1999
@@ -565,6 +565,9 @@
 	setaddr++;
 	if (doalias == 0)
 		clearaddr = 1;
+	if (afp->af_getaddr == NULL) {
+	    	errx(1,"setifaddr: no af_getaddr function for %s interfaces", afp->af_name);
+	}
 	(*afp->af_getaddr)(addr, (doalias >= 0 ? ADDR : RIDADDR));
 }
 
@@ -575,6 +578,9 @@
 	int s;
 	const struct afswtch *afp;
 {
+	if (afp->af_getaddr == NULL) {
+	    	errx(1,"setifnetmask: no af_getaddr function for %s interfaces", afp->af_name);
+	}
 	(*afp->af_getaddr)(addr, MASK);
 }
 
@@ -585,6 +591,9 @@
 	int s;
 	const struct afswtch *afp;
 {
+	if (afp->af_getaddr == NULL) {
+	    	errx(1,"setbroadaddr: no af_getaddr function for %s interfaces", afp->af_name);
+	}
 	(*afp->af_getaddr)(addr, DSTADDR);
 }
 



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: ru 
State-Changed-When: Wed Dec 29 05:53:30 PST 1999 
State-Changed-Why:  
Fixed in -current (src/sbin/ifconfig/ifconfig.c,v 1.47). 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Wed Dec 29 05:53:30 PST 1999 
Responsible-Changed-Why:  
So I remember to MFC. 
State-Changed-From-To: feedback->closed 
State-Changed-By: ru 
State-Changed-When: Tue Jan 11 04:34:34 PST 2000 
State-Changed-Why:  
Fixed in -stable (src/sbin/ifconfig/ifconfig.c,v 1.38.2.3). 
>Unformatted:
