diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2011-10-18 02:47:29 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-11-08 15:53:58 -0500 |
commit | ec3cbb9ce241da90b9d43e49996fae5082c6b6f7 (patch) | |
tree | a3f8740257c83acae7f47d35523aae803cebb0eb /drivers/net/wireless/rndis_wlan.c | |
parent | 48ef5c427ac2cfd12c150b38263d3ebb0d989647 (diff) |
rndis_wlan: add range check in del_key()
Wifi drivers can have up to 6 keys but the rndis_wlan only has 4 so
it needs to have its own checks to make sure we don't go out of
bounds. The add_key() function already checks but I added some
checks to del_key() and set_default_key().
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rndis_wlan.c')
-rw-r--r-- | drivers/net/wireless/rndis_wlan.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 0c13840a7de5..83f3e5282aea 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c | |||
@@ -414,6 +414,7 @@ struct ndis_80211_pmkid { | |||
414 | #define RNDIS_WLAN_ALG_TKIP (1<<1) | 414 | #define RNDIS_WLAN_ALG_TKIP (1<<1) |
415 | #define RNDIS_WLAN_ALG_CCMP (1<<2) | 415 | #define RNDIS_WLAN_ALG_CCMP (1<<2) |
416 | 416 | ||
417 | #define RNDIS_WLAN_NUM_KEYS 4 | ||
417 | #define RNDIS_WLAN_KEY_MGMT_NONE 0 | 418 | #define RNDIS_WLAN_KEY_MGMT_NONE 0 |
418 | #define RNDIS_WLAN_KEY_MGMT_802_1X (1<<0) | 419 | #define RNDIS_WLAN_KEY_MGMT_802_1X (1<<0) |
419 | #define RNDIS_WLAN_KEY_MGMT_PSK (1<<1) | 420 | #define RNDIS_WLAN_KEY_MGMT_PSK (1<<1) |
@@ -516,7 +517,7 @@ struct rndis_wlan_private { | |||
516 | 517 | ||
517 | /* encryption stuff */ | 518 | /* encryption stuff */ |
518 | int encr_tx_key_index; | 519 | int encr_tx_key_index; |
519 | struct rndis_wlan_encr_key encr_keys[4]; | 520 | struct rndis_wlan_encr_key encr_keys[RNDIS_WLAN_NUM_KEYS]; |
520 | int wpa_version; | 521 | int wpa_version; |
521 | 522 | ||
522 | u8 command_buffer[COMMAND_BUFFER_SIZE]; | 523 | u8 command_buffer[COMMAND_BUFFER_SIZE]; |
@@ -1535,6 +1536,9 @@ static int remove_key(struct usbnet *usbdev, int index, const u8 *bssid) | |||
1535 | bool is_wpa; | 1536 | bool is_wpa; |
1536 | int ret; | 1537 | int ret; |
1537 | 1538 | ||
1539 | if (index >= RNDIS_WLAN_NUM_KEYS) | ||
1540 | return -ENOENT; | ||
1541 | |||
1538 | if (priv->encr_keys[index].len == 0) | 1542 | if (priv->encr_keys[index].len == 0) |
1539 | return 0; | 1543 | return 0; |
1540 | 1544 | ||
@@ -2451,6 +2455,9 @@ static int rndis_set_default_key(struct wiphy *wiphy, struct net_device *netdev, | |||
2451 | 2455 | ||
2452 | netdev_dbg(usbdev->net, "%s(%i)\n", __func__, key_index); | 2456 | netdev_dbg(usbdev->net, "%s(%i)\n", __func__, key_index); |
2453 | 2457 | ||
2458 | if (key_index >= RNDIS_WLAN_NUM_KEYS) | ||
2459 | return -ENOENT; | ||
2460 | |||
2454 | priv->encr_tx_key_index = key_index; | 2461 | priv->encr_tx_key_index = key_index; |
2455 | 2462 | ||
2456 | if (is_wpa_key(priv, key_index)) | 2463 | if (is_wpa_key(priv, key_index)) |