Comment 3 for bug 98926

Revision history for this message
Roland (rolandonlinux) wrote :

Searching on IW_ESSID_MAX_SIZE across wlan drivers
shows many different ways to determine the length of the ESS-ID.
This could be simpler.

I'd suggest determine the length of the ESS string in a way that
works for both the old and the new version of wireless extensions,
by double checking if the last character is a \0 byte.

In the meantime, users should just enter a dummy character at
the end of the ESS in /etc/network/interfaces or the network config tool.

linux-source-2.6.20/ubuntu/wireless/acx/ioctl.c :

                if (dwrq->length > IW_ESSID_MAX_SIZE+1) {
                        result = -E2BIG;
                        goto end_unlock;
                }

                if (len > sizeof(adev->essid))
                        len = sizeof(adev->essid);
                memcpy(adev->essid, extra, len-1);
                adev->essid[len-1] = '\0';
                /* Paranoia: just in case there is a '\0'... */
                adev->essid_len = strlen(adev->essid);

at76/at76c503.c :

                memcpy(scan.essid, dev->essid, IW_ESSID_MAX_SIZE);
                scan.essid_size = dev->essid_size;

ipw3945/ipw3945.c :

#if WIRELESS_EXT > 20
#define IW_ESSID_FIX 0
#else
#define IW_ESSID_FIX 1
...
#endif

                length = wrqu->essid.length - IW_ESSID_FIX;

iwlwifi/base.c :

        essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
        while (essid_len--) {
                if (*s == '\0') {
                        *d++ = '\\';
                        *d++ = '0';
                        s++;
                } else {
                        *d++ = *s++;
                }
        }
        *d = '\0';

        ...

                priv->direct_ssid_len = (u8)
                    min((u8) len, (u8) IW_ESSID_MAX_SIZE);
                memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len);