[wpa_supplicant PATCH] Work around odd driver-reported ssid lengths



Hi,

At least the atmel and airo drivers do odd, technically incorrect,
things in their SIOCGIWESSID:

	memcpy(extra, status_rid.SSID, status_rid.SSIDlen);
	extra[status_rid.SSIDlen] = '\0';
	/* If none, we may want to get the one that was set */

	/* Push it out ! */
	dwrq->length = status_rid.SSIDlen + 1;

Atmel does roughly the same thing.  They both append a '\0' to the end,
and push that to userspace.  I'm unsure whether or not NULL is a legal
character in an SSID, but these drivers do it.

wpa_supplicant does not handle it; in the wpa_supplicant_get_ssid()
function, it compares the internal SSID from the config file to the
value returned by the driver.  If the lengths of the two do not match,
no wpa_ssid structure is returned.  In this odd case, then lengths do
not match, but the AP is clearly the correct AP to use.

Patch attached.  It checks if the last byte of the SSID reported by the
driver is NULL, and if so, decrements the driver-reported length.  I
think this is an acceptable solution.

Thanks,
Dan


--- wpa_supplicant.c.ssid-len	2006-01-10 00:13:09.000000000 -0500
+++ wpa_supplicant.c	2006-01-10 00:16:26.000000000 -0500
@@ -1429,6 +1429,10 @@
 	}
 	ssid_len = res;
 
+	/* Some drivers NULL the end and add one to the length */
+	if (ssid[ssid_len - 1] == '\0')
+		ssid_len--;
+
 	if (wpa_drv_get_bssid(wpa_s, bssid) < 0) {
 		wpa_printf(MSG_WARNING, "Could not read BSSID from driver.");
 		return NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]