Subject: bin/9648: ifconfig(1) fails to set flags
To: None <gnats-bugs@gnats.netbsd.org>
From: Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>
List: netbsd-bugs
Date: 03/21/2000 02:06:32
>Number:         9648
>Category:       bin
>Synopsis:       ifconfig(1) fails to set flags
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 21 02:06:00 2000
>Last-Modified:
>Originator:     Wolfgang Helbig
>Organization:
	
>Release:        Mar 20
>Environment:
	
System: NetBSD rvc1 1.4V NetBSD 1.4V (RVC1) #10: Tue Mar 21 08:14:01 CET 2000 root@rvc1:/usr/src/sys/arch/i386/compile/RVC1 i386


>Description:
>How-To-Repeat:
	The command
		ifconfig en0 debug
	fails with
		device not configured
>Fix:
	
	The field ifr_name must be set *before* the structure flagreq is
        passed to ioctl().
        Here is a patch to /usr/src/sbin/ifconfig/ifconfig.c:
Index: ifconfig.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.74
diff -u -r1.74 ifconfig.c
--- ifconfig.c	2000/03/18 21:10:50	1.74
+++ ifconfig.c	2000/03/21 09:46:06
@@ -830,9 +830,9 @@
 	char *vname;
 	int value;
 {
+	(void) strncpy(flagreq.ifr_name, name, sizeof (flagreq.ifr_name));
  	if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&flagreq) < 0)
 		err(1, "SIOCGIFFLAGS");
-	(void) strncpy(flagreq.ifr_name, name, sizeof (flagreq.ifr_name));
  	flags = flagreq.ifr_flags;
 
 	if (value < 0) {
>Audit-Trail:
>Unformatted: