libertas: work around non-WE-21-aware userspace tools

Dan Williams dcbw at localhost.unroutablelocaldomain
Fri Nov 10 21:24:37 EST 2006


Commit:     81d5913d581ec67ef043e425e45ce5ca48f54606
Parent:     eed178ab73eb7a589e4cd7451ed35cc003b800d3
commit 81d5913d581ec67ef043e425e45ce5ca48f54606
Author:     Dan Williams <dcbw at localhost.localdomain>
AuthorDate: Fri Nov 10 21:23:11 2006 -0500
Commit:     Dan Williams <dcbw at localhost.localdomain>
CommitDate: Fri Nov 10 21:23:11 2006 -0500

    libertas: work around non-WE-21-aware userspace tools
---
 drivers/net/wireless/libertas/wlan_join.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/libertas/wlan_join.c b/drivers/net/wireless/libertas/wlan_join.c
index f133eda..0023d1a 100644
--- a/drivers/net/wireless/libertas/wlan_join.c
+++ b/drivers/net/wireless/libertas/wlan_join.c
@@ -185,6 +185,7 @@ int libertas_set_essid(struct net_device
 	wlan_adapter *Adapter = priv->adapter;
 	int ret = WLAN_STATUS_SUCCESS;
 	struct WLAN_802_11_SSID reqSSID;
+	int ssid_len = dwrq->length;
 	int i;
 
 	ENTER();
@@ -199,8 +200,16 @@ #ifdef REASSOCIATION
 	}
 #endif				/* REASSOCIATION */
 
+	/*
+	 * WE-20 and earlier NULL pad the end of the SSID and increment
+	 * SSID length so it can be used like a string.  WE-21 and later don't,
+	 * but some userspace tools aren't able to cope with the change.
+	 */
+	if ((ssid_len > 0) && (extra[ssid_len - 1] == '\0'))
+		ssid_len--;
+
 	/* Check the size of the string */
-	if (dwrq->length > IW_ESSID_MAX_SIZE + 1) {
+	if (ssid_len > IW_ESSID_MAX_SIZE) {
 		ret = -E2BIG;
 		goto setessid_ret;
 	}
@@ -218,8 +227,8 @@ #endif				/* REASSOCIATION */
 		}
 	} else {
 		/* Set the SSID */
-		memcpy(reqSSID.Ssid, extra, dwrq->length);
-		reqSSID.SsidLength = dwrq->length - 1;
+		memcpy(reqSSID.Ssid, extra, ssid_len);
+		reqSSID.SsidLength = ssid_len;
 	}
 
 	PRINTM(INFO, "Requested new SSID = %s\n",


More information about the Commits-kernel mailing list