From cejkar@fit.vutbr.cz  Mon Mar 20 15:22:49 2006
Return-Path: <cejkar@fit.vutbr.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id EDD3416A438
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 20 Mar 2006 15:22:49 +0000 (UTC)
	(envelope-from cejkar@fit.vutbr.cz)
Received: from kazi.fit.vutbr.cz (kazi.fit.vutbr.cz [147.229.8.12])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 50D6743D55
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 20 Mar 2006 15:22:49 +0000 (GMT)
	(envelope-from cejkar@fit.vutbr.cz)
Received: from kazi.fit.vutbr.cz (localhost [127.0.0.1])
	by kazi.fit.vutbr.cz (envelope-from cejkar@fit.vutbr.cz) (8.13.5/8.13.5) with ESMTP id k2KFMlmc015963
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 20 Mar 2006 16:22:47 +0100 (CET)
Received: (from cejkar@localhost)
	by kazi.fit.vutbr.cz (8.13.5/8.13.1/Submit) id k2KFMlWV015962;
	Mon, 20 Mar 2006 16:22:47 +0100 (CET)
	(envelope-from cejkar)
Message-Id: <200603201522.k2KFMlWV015962@kazi.fit.vutbr.cz>
Date: Mon, 20 Mar 2006 16:22:47 +0100 (CET)
From: Rudolf Cejka <cejkar@fit.vutbr.cz>
Reply-To: Rudolf Cejka <cejkar@fit.vutbr.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] NDIS driver plus wpa_supplicant does not work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         94735
>Category:       bin
>Synopsis:       [wpa] [patch] NDIS driver plus wpa_supplicant does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 20 15:30:12 GMT 2006
>Closed-Date:    Wed Apr 12 17:24:40 GMT 2006
>Last-Modified:  Wed Apr 12 17:24:40 GMT 2006
>Originator:     Rudolf Cejka
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
FIT, Brno University of Technology, Czech Republic
>Environment:

FreeBSD 7.0-current Mar 17 2006

>Description:

Function PacketGetAdapterNames() in usr.sbin/wpa/wpa_supplicant/Packet32.c
has different semantics, than is expected by wpa_supplicant, which takes
result == 0 as an error and result != 0 as a success. Unfortunately
PacketGetAdapterNames() behaves in exactly different way.

>How-To-Repeat:
>Fix:

--- usr.sbin/wpa/wpa_supplicant/Packet32.c.orig	Mon Mar 20 16:07:18 2006
+++ usr.sbin/wpa/wpa_supplicant/Packet32.c	Mon Mar 20 16:07:50 2006
@@ -246,15 +246,15 @@
 	mib[5] = 0;             /* no flags */
 
 	if (sysctl (mib, 6, NULL, &needed, NULL, 0) < 0)
-		return(EIO);
+		return(0);
 
 	buf = malloc (needed);
 	if (buf == NULL)
-		return(ENOMEM);
+		return(0);
 
 	if (sysctl (mib, 6, buf, &needed, NULL, 0) < 0) {
 		free(buf);
-		return(EIO);
+		return(0);
 	}
 
 	lim = buf + needed;
@@ -269,7 +269,7 @@
 			if (strnstr(sdl->sdl_data, "ndis", sdl->sdl_nlen)) {
 				if ((spc + sdl->sdl_nlen) > *len) {
 					free(buf);
-					return(ENOSPC);
+					return(0);
 				}
 				strncpy(plist, sdl->sdl_data, sdl->sdl_nlen);
 				plist += (sdl->sdl_nlen + 1);
@@ -302,7 +302,7 @@
 			if (strnstr(sdl->sdl_data, "ndis", sdl->sdl_nlen)) {
 				if ((spc + sdl->sdl_nlen) > *len) {
 					free(buf);
-					return(ENOSPC);
+					return(0);
 				}
 				strncpy(plist, sdl->sdl_data, sdl->sdl_nlen);
 				plist += (sdl->sdl_nlen + 1);
@@ -317,7 +317,7 @@
 
 	*len = spc + 1;
 
-	return(0);
+	return(1);
 }
 
 void

PS: Here is another patch, if the bug is considered in wpa_supplicant:

--- contrib/wpa_supplicant/driver_ndis.c.orig	Mon Mar 20 16:00:40 2006
+++ contrib/wpa_supplicant/driver_ndis.c	Mon Mar 20 16:01:40 2006
@@ -1429,7 +1429,7 @@
 	memset(names, 0, len);
 
 	res = PacketGetAdapterNames(names, &len);
-	if (!res && len > 8192) {
+	if (res && len > 8192) {
 		free(names);
 		names = malloc(len);
 		if (names == NULL)
@@ -1438,7 +1438,7 @@
 		res = PacketGetAdapterNames(names, &len);
 	}
 
-	if (!res) {
+	if (res) {
 		wpa_printf(MSG_ERROR, "NDIS: Failed to get adapter list "
 			   "(PacketGetAdapterNames)");
 		free(names);
>Release-Note:
>Audit-Trail:

From: "Scot Hetzel" <swhetzel@gmail.com>
To: bug-followup@FreeBSD.org, cejkar@fit.vutbr.cz
Cc:  
Subject: Re: bin/94735: [wpa] [patch] NDIS driver plus wpa_supplicant does not work
Date: Sat, 1 Apr 2006 13:15:29 -0600

 I am seeing the same problem with wpa_supplicant not able to find the
 ndis interfaces.  I have solved the problem locally using a similar
 patch for Packet32.c as in this PR (used True/False instead of 1/0).
 
 The second patch in the PR shouldn't be used as it modifies vendor sources.
 
 This problem with wpa_supplicant and NDIS interfaces also affects
 FreeBSD 6.1-Beta4 and -CURRENT.
 
 Scot
 --
 DISCLAIMER:
 No electrons were mamed while sending this message. Only slightly bruised.

From: Nicolas Blais <nb_root@videotron.ca>
To: bug-followup@freebsd.org, cejkar@fit.vutbr.cz
Cc:  
Subject: Re: bin/94735: [wpa] [patch] NDIS driver plus wpa_supplicant does not
 work
Date: Mon, 03 Apr 2006 17:12:29 -0400

 Same annoying issue here on both -CURRENT and -STABLE, which the first patch 
 fixes.
 
 Could someone commit ASAP?
 
 Nicolas.
 
 -- 
 FreeBSD 7.0-CURRENT #0: Sat Apr  1 10:05:34 EST 2006     
 root@clk01a:/usr/obj/usr/src/sys/CLK01A 
 PGP? : http://www.clkroot.net/security/nb_root.asc

From: "Scot Hetzel" <swhetzel@gmail.com>
To: bug-followup@freebsd.org, wpaul@freebsd.org
Cc: cejkar@fit.vutbr.cz, sam@freebsd.org
Subject: Re: bin/94735: [wpa] [patch] NDIS driver plus wpa_supplicant does not work
Date: Mon, 10 Apr 2006 10:05:59 -0500

 ------=_Part_4355_30160582.1144681559464
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 Attached is the patch to src/usr.sbin/wpa/wpa_supplicant/Packet32.c
 that implements the winpcap AP{I,B} which uses TRUE/FALSE as the
 return values for PacketGetAdapterNames to indicate a success or
 failure to find the adapter name.
 
 http://www.winpcap.org/docs/man/html/Packet32_8c.html
 
 Please apply this patch to -CURRENT, RELENG_6, and RELENG_6_1.
 
 Scot
 --
 DISCLAIMER:
 No electrons were mamed while sending this message. Only slightly bruised.
 
 ------=_Part_4355_30160582.1144681559464
 Content-Type: text/plain; name=patch-Packet32.c; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 X-Attachment-Id: f_eluxm1jh
 Content-Disposition: attachment; filename="patch-Packet32.c"
 
 Index: Packet32.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/wpa/wpa_supplicant/Packet32.c,v
 retrieving revision 1.2.2.1
 diff -u -r1.2.2.1 Packet32.c
 --- Packet32.c	27 Oct 2005 17:06:47 -0000	1.2.2.1
 +++ Packet32.c	31 Mar 2006 01:37:18 -0000
 @@ -246,15 +246,15 @@
  	mib[5] = 0;             /* no flags */
  
  	if (sysctl (mib, 6, NULL, &needed, NULL, 0) < 0)
 -		return(EIO);
 +		return(FALSE);
  
  	buf = malloc (needed);
  	if (buf == NULL)
 -		return(ENOMEM);
 +		return(FALSE);
  
  	if (sysctl (mib, 6, buf, &needed, NULL, 0) < 0) {
  		free(buf);
 -		return(EIO);
 +		return(FALSE);
  	}
  
  	lim = buf + needed;
 @@ -269,7 +269,7 @@
  			if (strnstr(sdl->sdl_data, "ndis", sdl->sdl_nlen)) {
  				if ((spc + sdl->sdl_nlen) > *len) {
  					free(buf);
 -					return(ENOSPC);
 +					return(FALSE);
  				}
  				strncpy(plist, sdl->sdl_data, sdl->sdl_nlen);
  				plist += (sdl->sdl_nlen + 1);
 @@ -302,7 +302,7 @@
  			if (strnstr(sdl->sdl_data, "ndis", sdl->sdl_nlen)) {
  				if ((spc + sdl->sdl_nlen) > *len) {
  					free(buf);
 -					return(ENOSPC);
 +					return(FALSE);
  				}
  				strncpy(plist, sdl->sdl_data, sdl->sdl_nlen);
  				plist += (sdl->sdl_nlen + 1);
 @@ -317,7 +317,7 @@
  
  	*len = spc + 1;
  
 -	return(0);
 +	return(TRUE);
  }
  
  void
 
 
 
 
 ------=_Part_4355_30160582.1144681559464--
State-Changed-From-To: open->closed 
State-Changed-By: sam 
State-Changed-When: Wed Apr 12 17:23:34 UTC 2006 
State-Changed-Why:  
patch to Packet32.c applied in head and releng6; thank you! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=94735 
>Unformatted:
