Skip to contentSkip to conversation

use NLA_BINARY in nl80211

FYI Johannes Berg 1 participant 1 message Mar 29, 2007 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

Unfortunately I hadn't noticed when starting nl80211 that NLA_STRING validation removes a trailing \0. This means that we have a problem right now with SSIDs for example in nl80211 when they end with \0, or, more importantly maybe, with key data as well.

This patch changes this to use the new NLA_BINARY attribute type I created but which isn't in wireless-dev yet, it is in davem's .22 branch though.

---
 net/wireless/nl80211.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
net/wireless/nl80211.c +6 -5
@@ -75,7 +75,7 @@ static struct nla_policy nl80211_policy[
 				      .len = BUS_ID_SIZE-1 },
 	[NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
 	[NL80211_ATTR_BSSID] = { .len = ETH_ALEN },
-	[NL80211_ATTR_SSID] = { .type = NLA_STRING,
+	[NL80211_ATTR_SSID] = { .type = NLA_BINARY,
 				.len = IEEE80211_MAX_SSID_LEN },
 	[NL80211_ATTR_CHANNEL] = { .type = NLA_U32 },
 	[NL80211_ATTR_PHYMODE] = { .type = NLA_U32 },
@@ -85,7 +85,7 @@ static struct nla_policy nl80211_policy[
 	[NL80211_ATTR_BEACON_PERIOD] = { .type = NLA_U32 },
 	[NL80211_ATTR_DTIM_PERIOD] = { .type = NLA_U32 },
 	[NL80211_ATTR_TIMESTAMP] = { .type = NLA_U64 },
-	[NL80211_ATTR_IE] = { .type = NLA_STRING, .len = NL80211_MAX_IE_LEN },
+	[NL80211_ATTR_IE] = { .type = NLA_BINARY, .len = NL80211_MAX_IE_LEN },
 	[NL80211_ATTR_AUTH_ALGORITHM] = { .type = NLA_U32 },
 	[NL80211_ATTR_TIMEOUT_TU] = { .type = NLA_U32 },
 	[NL80211_ATTR_REASON_CODE] = { .type = NLA_U32 },
@@ -95,9 +95,10 @@ static struct nla_policy nl80211_policy[
 	[NL80211_ATTR_TRANSMIT_POWER] = { .type = NLA_U32 },
 	[NL80211_ATTR_FRAG_THRESHOLD] = { .type = NLA_U32 },
 	[NL80211_ATTR_FLAG_SCAN_ACTIVE] = { .type = NLA_FLAG },
-	[NL80211_ATTR_BEACON_HEAD] = { .type = NLA_STRING },
-	[NL80211_ATTR_BEACON_TAIL] = { .type = NLA_STRING },
-	[NL80211_ATTR_KEY_DATA] = { .type = NLA_STRING, .len = WLAN_MAX_KEY_LEN },
+	[NL80211_ATTR_BEACON_HEAD] = { .type = NLA_BINARY },
+	[NL80211_ATTR_BEACON_TAIL] = { .type = NLA_BINARY },
+	[NL80211_ATTR_KEY_DATA] = { .type = NLA_BINARY,
+				    .len = WLAN_MAX_KEY_LEN },
 	[NL80211_ATTR_KEY_ID] = { .type = NLA_U32 },
 	[NL80211_ATTR_KEY_TYPE] = { .type = NLA_U32 },
 	[NL80211_ATTR_MAC] = { .len = ETH_ALEN },