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

Jouni Malinen jkmaline
Sun Jan 29 10:55:35 PST 2006


On Thu, Jan 12, 2006 at 11:30:37AM -0500, Dan Williams wrote:

> 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;

Whether this is incorrect or not is somewhat open topic since len+1 is
used on SIOCSIWESSID for historic reasons.. SIOCGIWESSID seems to have
more variance on what the drivers are doing.

> 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! I agree that wpa_supplicant should work around the driver
differences. However, I made a similar change for driver_wext.c since
this API difference is specific to Linux wireless extensions and there
is no reason to do this for other driver interfaces, i.e., no point in
breaking the admittedly unlikely case of using '\0' as the last octet in
SSID with other driver interfaces. In addition, better make sure we do
not change ssid_len from 0 to -1 if the driver were to return zero as
the length.

-- 
Jouni Malinen                                            PGP id EFC895FA




More information about the Hostap mailing list