Subject: bin/23774: wiconfig exits on non-critical errors
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jacereda@users.sourceforge.net>
List: netbsd-bugs
Date: 12/16/2003 20:17:42
>Number:         23774
>Category:       bin
>Synopsis:       wiconfig exits on non-critical errors
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 16 18:31:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Jorge Acereda
>Release:        NetBSD 1.6ZG
>Organization:
	
>Environment:
	
	
System: NetBSD locus.dlsi 1.6ZG NetBSD 1.6ZG (LOCUS) #21: Tue Dec 16 17:30:53 CET 2003 root@locus.dlsi:/sys/arch/i386/compile/LOCUS i386
Architecture: i386
Machine: i386
>Description:
	

If wiconfig attempts an unimplemented ioctl(), the code calls err()
and leaves. This isn't desirable, as it doesn't permit to see the rest
of the output.
 
>How-To-Repeat:
	

Attach an ath device to your computer and compile a kernel with ath support.

$ wiconfig ath0
NIC serial number:			[  ]
Station name:				[ locus.dlsi ]
SSID for IBSS creation:			[ LOCUS ]
Current netname (SSID):			[ LOCUS ]
Desired netname (SSID):			[ LOCUS ]
Current BSSID:				[ 00:09:5b:92:6d:72 ]
Channel list:				[ 2 3 4 5 6 7 8 9 10 11 12 ]
IBSS channel:				[ 3 ]
Current channel:			[ 3 ]
Comms quality/signal/noise:		[ 0 37 0 ]
Promiscuous mode:			[ Off ]
Port type:				[ 6 ]
MAC address:				[ 00:09:5b:92:6d:72 ]
TX rate (selection):			[ 0 ]
TX rate (actual speed):			[ 11 ]
Beacon Interval (current) [msec]:	[ 100 ]
Maximum data length:			[ 2312 ]
RTS/CTS handshake threshold:		[ 2312 ]
fragmentation threshold:		[ 2346 ]
wiconfig: SIOCGWAVELAN: Invalid argument

>Fix:
	

The following patch adds a return value to wi_getval() and makes it
call warn() instead of err().

After applying:

$ wiconfig ath0
NIC serial number:			[  ]
Station name:				[ locus.dlsi ]
SSID for IBSS creation:			[ LOCUS ]
Current netname (SSID):			[ LOCUS ]
Desired netname (SSID):			[ LOCUS ]
Current BSSID:				[ 00:09:5b:92:6d:72 ]
Channel list:				[ 2 3 4 5 6 7 8 9 10 11 12 ]
IBSS channel:				[ 3 ]
Current channel:			[ 3 ]
Comms quality/signal/noise:		[ 0 35 0 ]
Promiscuous mode:			[ Off ]
Port type:				[ 6 ]
MAC address:				[ 00:09:5b:92:6d:72 ]
TX rate (selection):			[ 0 ]
TX rate (actual speed):			[ 11 ]
Beacon Interval (current) [msec]:	[ 100 ]
Maximum data length:			[ 2312 ]
RTS/CTS handshake threshold:		[ 2312 ]
fragmentation threshold:		[ 2346 ]
wiconfig: SIOCGWAVELAN: Invalid argument
RSSI -> dBm adjustment:			[ Unknown ]
Create IBSS:				[ Off ]
Microwave oven robustness:		[ 0 ]
Roaming mode(1:firm,3:disable):		[ 1 ]
Access point density:			[ 1 ]
Power Mgmt (1=on, 0=off):		[ 0 ]
Max sleep time (msec):			[ 100 ]
wiconfig: SIOCGWAVELAN: Invalid argument
Vendor info:				[ Unknown ]
WEP encryption:				[ Off ]
Authentication type 
(1=OpenSys, 2=Shared Key):		[ 1 ]
TX encryption key:			[ 1 ]
Encryption keys:			[  ][  ][  ][  ]


Index: usr.sbin/wiconfig/wiconfig.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/wiconfig/wiconfig.c,v
retrieving revision 1.32
diff -u -r1.32 wiconfig.c
--- usr.sbin/wiconfig/wiconfig.c	2003/11/16 09:41:01	1.32
+++ usr.sbin/wiconfig/wiconfig.c	2003/12/16 17:27:53
@@ -102,7 +102,7 @@
 static int  get_if_flags	__P((int, const char *));
 static int  set_if_flags	__P((int, const char *, int));
 #endif
-static void wi_getval		__P((char *, struct wi_req *));
+static int  wi_getval		__P((char *, struct wi_req *));
 static void wi_setval		__P((char *, struct wi_req *));
 static void wi_printstr		__P((struct wi_req *));
 static void wi_setstr		__P((char *, int, char *));
@@ -285,13 +285,15 @@
 }
 #endif
 
-static void wi_getval(iface, wreq)
+static int wi_getval(iface, wreq)
 	char			*iface;
 	struct wi_req		*wreq;
 {
 	struct ifreq		ifr;
 	int			s;
+	int			error;
 
+	error = 0;
 	bzero((char *)&ifr, sizeof(ifr));
 
 	strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
@@ -303,11 +305,14 @@
 		err(1, "socket");
 
 	if (ioctl(s, SIOCGWAVELAN, &ifr) == -1)
-		err(1, "SIOCGWAVELAN");
+	{
+		warn("SIOCGWAVELAN");
+		error = 1;
+	}
 
 	close(s);
 
-	return;
+	return error;
 }
 
 static void wi_setval(iface, wreq)
@@ -658,8 +663,12 @@
 		wreq.wi_len = WI_MAX_DATALEN;
 		wreq.wi_type = w[i].wi_type;
 
-		wi_getval(iface, &wreq);
 		printf("%s", w[i].wi_label);
+		if (wi_getval(iface, &wreq))
+		{
+			printf("[ Unknown ]\n");
+			continue;
+		}
 		switch (w[i].wi_code) {
 		case WI_STRING:
 			wi_printstr(&wreq);


>Release-Note:
>Audit-Trail:
>Unformatted: