crda: fix null string assumption for alpha2
authorLuis R. Rodriguez <mcgrof@qca.qualcomm.com>
Fri, 7 Oct 2011 20:47:53 +0000 (13:47 -0700)
committerLuis R. Rodriguez <mcgrof@qca.qualcomm.com>
Mon, 10 Oct 2011 23:21:54 +0000 (16:21 -0700)
commite40afba19fef7c0c76939efc9ca4a593dfdaa840
tree79ea8541949bd1591348368a479fec4e6cc2a29a
parentf9d15dc6a7a69e07f7e363304a0871a9485d5637
crda: fix null string assumption for alpha2

The wireless-regdb only accounts for two bytes for
the country code but CRDA defined the alpha2 to be
as a string of length 2, and so does the nl80211 attribute
policy:

        [NL80211_ATTR_REG_ALPHA2] = { .type = NLA_STRING, .len = 2 },

The meaning of a string is it'll be null terminated, so if you
do not add the null termination a country without the null termination
will not match up with the nl80211 attribute policy.

This has no impact for us unless we want to use the next available
pad byte on the wireless-regdb. This fixes CRDA by using a local copy
of the regdb's alpha2 that is properly null terminated and sending it.

The implications of this change is that new wirelesss-regdb's that
make use of the next pad byte for a country will get that country
ignored for regulatory hints sent to the kernel. At this point we
don't yet know what the next byte will be used for though so this
has no impact. The second pad byte is being used for DFS and that
is not impacted by this nor is this change required for it.

Distributions should upgrade though in case we ever do decide to use
this last precious country byte. I've tested that this indeed fixes
the bogus issue I saw when instead of using the second pad byte we
use the first pad byte. Thanks to Johannes for spotting the issue.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
crda.c
reglib.h