public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cfg80211: fix a couple of bugs with key ioctls
@ 2009-05-12 10:44 Johannes Berg
  2009-05-12 19:05 ` Hin-Tak Leung
  2009-05-13 10:10 ` [PATCH v2] " Johannes Berg
  0 siblings, 2 replies; 12+ messages in thread
From: Johannes Berg @ 2009-05-12 10:44 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, Hin-Tak Leung

There are a few small bugs/oversights in the key handling
code I wrote:
 * SIOCSIWENCODE should default to setting key 0 if no
   default key is set already and no index is given,
 * key removal should not require key material,
 * SIOCSIWENCODEEXT should default to changing the default
   management key if no index is given.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/wireless/wext-compat.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

--- wireless-testing.orig/net/wireless/wext-compat.c	2009-05-12 12:38:41.000000000 +0200
+++ wireless-testing/net/wireless/wext-compat.c	2009-05-12 12:38:59.000000000 +0200
@@ -557,7 +557,7 @@ int cfg80211_wext_siwencode(struct net_d
 	if (idx == 0) {
 		idx = wdev->wext.default_key;
 		if (idx < 0)
-			return -EINVAL;
+			idx = 0;
 	} else if (idx < 1 || idx > 4)
 		return -EINVAL;
 	else
@@ -580,7 +580,7 @@ int cfg80211_wext_siwencode(struct net_d
 		params.cipher = WLAN_CIPHER_SUITE_WEP40;
 	else if (erq->length == 13)
 		params.cipher = WLAN_CIPHER_SUITE_WEP104;
-	else
+	else if (!remove)
 		return -EINVAL;
 
 	return cfg80211_set_encryption(rdev, dev, NULL, remove,
@@ -640,13 +640,9 @@ int cfg80211_wext_siwencodeext(struct ne
 	idx = erq->flags & IW_ENCODE_INDEX;
 	if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
 		if (idx < 4 || idx > 5) {
-			/*
-			 * XXX: Only wpa_supplicant ever used this
-			 *	can we still change the ABI a little
-			 *	so we do not need to keep track of
-			 *	the default key?
-			 */
-			return -EINVAL;
+			idx = wdev->wext.default_mgmt_key;
+			if (idx < 0)
+				return -EINVAL;
 		} else
 			idx--;
 	} else {



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-05-13 13:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-12 10:44 [PATCH] cfg80211: fix a couple of bugs with key ioctls Johannes Berg
2009-05-12 19:05 ` Hin-Tak Leung
2009-05-12 19:08   ` Hin-Tak Leung
2009-05-12 19:27     ` Johannes Berg
2009-05-12 19:59       ` Hin-Tak Leung
2009-05-12 21:00         ` Hin-Tak Leung
2009-05-13  3:56           ` Hin-Tak Leung
2009-05-13  9:04             ` Johannes Berg
2009-05-13 13:24               ` Dan Williams
2009-05-12 19:20   ` Johannes Berg
2009-05-13 10:10 ` [PATCH v2] " Johannes Berg
2009-05-13 13:27   ` Hin-Tak Leung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox