diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2011-10-18 02:50:43 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-11-08 15:53:59 -0500 |
commit | 5a5ee76e09b1f5a3a550127aecc2ea4d59f17963 (patch) | |
tree | 66e9d4a71f6b22cc488260f28444fc197d6ff751 /drivers/net/wireless/iwmc3200wifi | |
parent | ec3cbb9ce241da90b9d43e49996fae5082c6b6f7 (diff) |
iwmc3200wifi: add some more range checks
My previous patch added a check to get_key() but missed a couple
other places which need range checks.
The problem here is that wifi drivers have different numbers of keys.
The lower levels assume that they can have up to 4 default keys and
2 management keys but this driver only has the default keys so we
could go past the end of the ->keys[] array.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwmc3200wifi')
-rw-r--r-- | drivers/net/wireless/iwmc3200wifi/cfg80211.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c index c42be81e979e..48e8218fd23b 100644 --- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c +++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c | |||
@@ -165,11 +165,15 @@ static int iwm_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, | |||
165 | struct key_params *params) | 165 | struct key_params *params) |
166 | { | 166 | { |
167 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | 167 | struct iwm_priv *iwm = ndev_to_iwm(ndev); |
168 | struct iwm_key *key = &iwm->keys[key_index]; | 168 | struct iwm_key *key; |
169 | int ret; | 169 | int ret; |
170 | 170 | ||
171 | IWM_DBG_WEXT(iwm, DBG, "Adding key for %pM\n", mac_addr); | 171 | IWM_DBG_WEXT(iwm, DBG, "Adding key for %pM\n", mac_addr); |
172 | 172 | ||
173 | if (key_index >= IWM_NUM_KEYS) | ||
174 | return -ENOENT; | ||
175 | |||
176 | key = &iwm->keys[key_index]; | ||
173 | memset(key, 0, sizeof(struct iwm_key)); | 177 | memset(key, 0, sizeof(struct iwm_key)); |
174 | ret = iwm_key_init(key, key_index, mac_addr, params); | 178 | ret = iwm_key_init(key, key_index, mac_addr, params); |
175 | if (ret < 0) { | 179 | if (ret < 0) { |
@@ -214,8 +218,12 @@ static int iwm_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, | |||
214 | u8 key_index, bool pairwise, const u8 *mac_addr) | 218 | u8 key_index, bool pairwise, const u8 *mac_addr) |
215 | { | 219 | { |
216 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | 220 | struct iwm_priv *iwm = ndev_to_iwm(ndev); |
217 | struct iwm_key *key = &iwm->keys[key_index]; | 221 | struct iwm_key *key; |
218 | 222 | ||
223 | if (key_index >= IWM_NUM_KEYS) | ||
224 | return -ENOENT; | ||
225 | |||
226 | key = &iwm->keys[key_index]; | ||
219 | if (!iwm->keys[key_index].key_len) { | 227 | if (!iwm->keys[key_index].key_len) { |
220 | IWM_DBG_WEXT(iwm, DBG, "Key %d not used\n", key_index); | 228 | IWM_DBG_WEXT(iwm, DBG, "Key %d not used\n", key_index); |
221 | return 0; | 229 | return 0; |
@@ -236,6 +244,9 @@ static int iwm_cfg80211_set_default_key(struct wiphy *wiphy, | |||
236 | 244 | ||
237 | IWM_DBG_WEXT(iwm, DBG, "Default key index is: %d\n", key_index); | 245 | IWM_DBG_WEXT(iwm, DBG, "Default key index is: %d\n", key_index); |
238 | 246 | ||
247 | if (key_index >= IWM_NUM_KEYS) | ||
248 | return -ENOENT; | ||
249 | |||
239 | if (!iwm->keys[key_index].key_len) { | 250 | if (!iwm->keys[key_index].key_len) { |
240 | IWM_ERR(iwm, "Key %d not used\n", key_index); | 251 | IWM_ERR(iwm, "Key %d not used\n", key_index); |
241 | return -EINVAL; | 252 | return -EINVAL; |