diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2007-12-19 19:21:51 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:09:01 -0500 |
commit | 4293ea33c8a85c3b4401df5df82fc3e070ec0c8e (patch) | |
tree | 9dc46ea630e07a8adc8494c01415f28156e394f0 /drivers/net/wireless | |
parent | 17e70491404c73012a7991a068ba62ec59bebdb2 (diff) |
airo: sanitize handling of WepKeyRid
don't byteswap, update users to match that, annotate.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/airo.c | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index a619af6960a7..8eac7fb4521d 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -501,10 +501,10 @@ typedef struct { | |||
501 | /* This structure came from an email sent to me from an engineer at | 501 | /* This structure came from an email sent to me from an engineer at |
502 | aironet for inclusion into this driver */ | 502 | aironet for inclusion into this driver */ |
503 | typedef struct { | 503 | typedef struct { |
504 | u16 len; | 504 | __le16 len; |
505 | u16 kindex; | 505 | __le16 kindex; |
506 | u8 mac[ETH_ALEN]; | 506 | u8 mac[ETH_ALEN]; |
507 | u16 klen; | 507 | __le16 klen; |
508 | u8 key[16]; | 508 | u8 key[16]; |
509 | } WepKeyRid; | 509 | } WepKeyRid; |
510 | 510 | ||
@@ -1750,31 +1750,22 @@ static int readBSSListRid(struct airo_info *ai, int first, | |||
1750 | list, ai->bssListRidLen, 1); | 1750 | list, ai->bssListRidLen, 1); |
1751 | } | 1751 | } |
1752 | 1752 | ||
1753 | static int readWepKeyRid(struct airo_info*ai, WepKeyRid *wkr, int temp, int lock) { | 1753 | static int readWepKeyRid(struct airo_info *ai, WepKeyRid *wkr, int temp, int lock) |
1754 | int rc = PC4500_readrid(ai, temp ? RID_WEP_TEMP : RID_WEP_PERM, | 1754 | { |
1755 | return PC4500_readrid(ai, temp ? RID_WEP_TEMP : RID_WEP_PERM, | ||
1755 | wkr, sizeof(*wkr), lock); | 1756 | wkr, sizeof(*wkr), lock); |
1756 | |||
1757 | wkr->len = le16_to_cpu(wkr->len); | ||
1758 | wkr->kindex = le16_to_cpu(wkr->kindex); | ||
1759 | wkr->klen = le16_to_cpu(wkr->klen); | ||
1760 | return rc; | ||
1761 | } | 1757 | } |
1762 | /* In the writeXXXRid routines we copy the rids so that we don't screwup | ||
1763 | * the originals when we endian them... */ | ||
1764 | static int writeWepKeyRid(struct airo_info*ai, WepKeyRid *pwkr, int perm, int lock) { | ||
1765 | int rc; | ||
1766 | WepKeyRid wkr = *pwkr; | ||
1767 | 1758 | ||
1768 | wkr.len = cpu_to_le16(wkr.len); | 1759 | static int writeWepKeyRid(struct airo_info *ai, WepKeyRid *wkr, int perm, int lock) |
1769 | wkr.kindex = cpu_to_le16(wkr.kindex); | 1760 | { |
1770 | wkr.klen = cpu_to_le16(wkr.klen); | 1761 | int rc; |
1771 | rc = PC4500_writerid(ai, RID_WEP_TEMP, &wkr, sizeof(wkr), lock); | 1762 | rc = PC4500_writerid(ai, RID_WEP_TEMP, wkr, sizeof(*wkr), lock); |
1772 | if (rc!=SUCCESS) airo_print_err(ai->dev->name, "WEP_TEMP set %x", rc); | 1763 | if (rc!=SUCCESS) |
1764 | airo_print_err(ai->dev->name, "WEP_TEMP set %x", rc); | ||
1773 | if (perm) { | 1765 | if (perm) { |
1774 | rc = PC4500_writerid(ai, RID_WEP_PERM, &wkr, sizeof(wkr), lock); | 1766 | rc = PC4500_writerid(ai, RID_WEP_PERM, wkr, sizeof(*wkr), lock); |
1775 | if (rc!=SUCCESS) { | 1767 | if (rc!=SUCCESS) |
1776 | airo_print_err(ai->dev->name, "WEP_PERM set %x", rc); | 1768 | airo_print_err(ai->dev->name, "WEP_PERM set %x", rc); |
1777 | } | ||
1778 | } | 1769 | } |
1779 | return rc; | 1770 | return rc; |
1780 | } | 1771 | } |
@@ -3755,7 +3746,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) | |||
3755 | int status; | 3746 | int status; |
3756 | int i; | 3747 | int i; |
3757 | SsidRid mySsid; | 3748 | SsidRid mySsid; |
3758 | u16 lastindex; | 3749 | __le16 lastindex; |
3759 | WepKeyRid wkr; | 3750 | WepKeyRid wkr; |
3760 | int rc; | 3751 | int rc; |
3761 | 3752 | ||
@@ -3891,7 +3882,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) | |||
3891 | rc = readWepKeyRid(ai, &wkr, 1, lock); | 3882 | rc = readWepKeyRid(ai, &wkr, 1, lock); |
3892 | if (rc == SUCCESS) do { | 3883 | if (rc == SUCCESS) do { |
3893 | lastindex = wkr.kindex; | 3884 | lastindex = wkr.kindex; |
3894 | if (wkr.kindex == 0xffff) { | 3885 | if (wkr.kindex == cpu_to_le16(0xffff)) { |
3895 | ai->defindex = wkr.mac[0]; | 3886 | ai->defindex = wkr.mac[0]; |
3896 | } | 3887 | } |
3897 | rc = readWepKeyRid(ai, &wkr, 0, lock); | 3888 | rc = readWepKeyRid(ai, &wkr, 0, lock); |
@@ -5197,39 +5188,40 @@ static int do_writerid( struct airo_info *ai, u16 rid, const void *rid_data, | |||
5197 | static int get_wep_key(struct airo_info *ai, u16 index) { | 5188 | static int get_wep_key(struct airo_info *ai, u16 index) { |
5198 | WepKeyRid wkr; | 5189 | WepKeyRid wkr; |
5199 | int rc; | 5190 | int rc; |
5200 | u16 lastindex; | 5191 | __le16 lastindex; |
5201 | 5192 | ||
5202 | rc = readWepKeyRid(ai, &wkr, 1, 1); | 5193 | rc = readWepKeyRid(ai, &wkr, 1, 1); |
5203 | if (rc == SUCCESS) do { | 5194 | if (rc == SUCCESS) do { |
5204 | lastindex = wkr.kindex; | 5195 | lastindex = wkr.kindex; |
5205 | if (wkr.kindex == index) { | 5196 | if (wkr.kindex == cpu_to_le16(index)) { |
5206 | if (index == 0xffff) { | 5197 | if (index == 0xffff) { |
5207 | return wkr.mac[0]; | 5198 | return wkr.mac[0]; |
5208 | } | 5199 | } |
5209 | return wkr.klen; | 5200 | return le16_to_cpu(wkr.klen); |
5210 | } | 5201 | } |
5211 | readWepKeyRid(ai, &wkr, 0, 1); | 5202 | readWepKeyRid(ai, &wkr, 0, 1); |
5212 | } while(lastindex != wkr.kindex); | 5203 | } while (lastindex != wkr.kindex); |
5213 | return -1; | 5204 | return -1; |
5214 | } | 5205 | } |
5215 | 5206 | ||
5216 | static int set_wep_key(struct airo_info *ai, u16 index, | 5207 | static int set_wep_key(struct airo_info *ai, u16 index, |
5217 | const char *key, u16 keylen, int perm, int lock ) { | 5208 | const char *key, u16 keylen, int perm, int lock ) |
5209 | { | ||
5218 | static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; | 5210 | static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; |
5219 | WepKeyRid wkr; | 5211 | WepKeyRid wkr; |
5220 | 5212 | ||
5221 | memset(&wkr, 0, sizeof(wkr)); | 5213 | memset(&wkr, 0, sizeof(wkr)); |
5222 | if (keylen == 0) { | 5214 | if (keylen == 0) { |
5223 | // We are selecting which key to use | 5215 | // We are selecting which key to use |
5224 | wkr.len = sizeof(wkr); | 5216 | wkr.len = cpu_to_le16(sizeof(wkr)); |
5225 | wkr.kindex = 0xffff; | 5217 | wkr.kindex = cpu_to_le16(0xffff); |
5226 | wkr.mac[0] = (char)index; | 5218 | wkr.mac[0] = (char)index; |
5227 | if (perm) ai->defindex = (char)index; | 5219 | if (perm) ai->defindex = (char)index; |
5228 | } else { | 5220 | } else { |
5229 | // We are actually setting the key | 5221 | // We are actually setting the key |
5230 | wkr.len = sizeof(wkr); | 5222 | wkr.len = cpu_to_le16(sizeof(wkr)); |
5231 | wkr.kindex = index; | 5223 | wkr.kindex = cpu_to_le16(index); |
5232 | wkr.klen = keylen; | 5224 | wkr.klen = cpu_to_le16(keylen); |
5233 | memcpy( wkr.key, key, keylen ); | 5225 | memcpy( wkr.key, key, keylen ); |
5234 | memcpy( wkr.mac, macaddr, ETH_ALEN ); | 5226 | memcpy( wkr.mac, macaddr, ETH_ALEN ); |
5235 | } | 5227 | } |
@@ -5281,14 +5273,15 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { | |||
5281 | set_wep_key(ai, index, key, i/3, 1, 1); | 5273 | set_wep_key(ai, index, key, i/3, 1, 1); |
5282 | } | 5274 | } |
5283 | 5275 | ||
5284 | static int proc_wepkey_open( struct inode *inode, struct file *file ) { | 5276 | static int proc_wepkey_open( struct inode *inode, struct file *file ) |
5277 | { | ||
5285 | struct proc_data *data; | 5278 | struct proc_data *data; |
5286 | struct proc_dir_entry *dp = PDE(inode); | 5279 | struct proc_dir_entry *dp = PDE(inode); |
5287 | struct net_device *dev = dp->data; | 5280 | struct net_device *dev = dp->data; |
5288 | struct airo_info *ai = dev->priv; | 5281 | struct airo_info *ai = dev->priv; |
5289 | char *ptr; | 5282 | char *ptr; |
5290 | WepKeyRid wkr; | 5283 | WepKeyRid wkr; |
5291 | u16 lastindex; | 5284 | __le16 lastindex; |
5292 | int j=0; | 5285 | int j=0; |
5293 | int rc; | 5286 | int rc; |
5294 | 5287 | ||
@@ -5314,12 +5307,13 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) { | |||
5314 | rc = readWepKeyRid(ai, &wkr, 1, 1); | 5307 | rc = readWepKeyRid(ai, &wkr, 1, 1); |
5315 | if (rc == SUCCESS) do { | 5308 | if (rc == SUCCESS) do { |
5316 | lastindex = wkr.kindex; | 5309 | lastindex = wkr.kindex; |
5317 | if (wkr.kindex == 0xffff) { | 5310 | if (wkr.kindex == cpu_to_le16(0xffff)) { |
5318 | j += sprintf(ptr+j, "Tx key = %d\n", | 5311 | j += sprintf(ptr+j, "Tx key = %d\n", |
5319 | (int)wkr.mac[0]); | 5312 | (int)wkr.mac[0]); |
5320 | } else { | 5313 | } else { |
5321 | j += sprintf(ptr+j, "Key %d set with length = %d\n", | 5314 | j += sprintf(ptr+j, "Key %d set with length = %d\n", |
5322 | (int)wkr.kindex, (int)wkr.klen); | 5315 | le16_to_cpu(wkr.kindex), |
5316 | le16_to_cpu(wkr.klen)); | ||
5323 | } | 5317 | } |
5324 | readWepKeyRid(ai, &wkr, 0, 1); | 5318 | readWepKeyRid(ai, &wkr, 0, 1); |
5325 | } while((lastindex != wkr.kindex) && (j < 180-30)); | 5319 | } while((lastindex != wkr.kindex) && (j < 180-30)); |