aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2007-12-27 16:15:11 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:46 -0500
commit47f76ca3a34cd6571a2de39da2926123ca39a4c1 (patch)
treef9924200068ff173a23f811b3dcee565a3fccbea /drivers/net/wireless/b43
parent280d0e16bcbf5893505a0d0897f3ca1ddc0764fa (diff)
b43: Fix tim search buffer overrun
Use the length of the variable section of the beacon instead of the whole beacon length for bounds checking. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43')
-rw-r--r--drivers/net/wireless/b43/main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 345ac3862e11..a15a45b789b1 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1163,7 +1163,7 @@ static void b43_write_beacon_template(struct b43_wldev *dev,
1163 u16 ram_offset, 1163 u16 ram_offset,
1164 u16 shm_size_offset, u8 rate) 1164 u16 shm_size_offset, u8 rate)
1165{ 1165{
1166 int i, len; 1166 unsigned int i, len, variable_len;
1167 const struct ieee80211_mgmt *bcn; 1167 const struct ieee80211_mgmt *bcn;
1168 const u8 *ie; 1168 const u8 *ie;
1169 bool tim_found = 0; 1169 bool tim_found = 0;
@@ -1178,7 +1178,8 @@ static void b43_write_beacon_template(struct b43_wldev *dev,
1178 /* Find the position of the TIM and the DTIM_period value 1178 /* Find the position of the TIM and the DTIM_period value
1179 * and write them to SHM. */ 1179 * and write them to SHM. */
1180 ie = bcn->u.beacon.variable; 1180 ie = bcn->u.beacon.variable;
1181 for (i = 0; i < len - 2; ) { 1181 variable_len = len - offsetof(struct ieee80211_mgmt, u.beacon.variable);
1182 for (i = 0; i < variable_len - 2; ) {
1182 uint8_t ie_id, ie_len; 1183 uint8_t ie_id, ie_len;
1183 1184
1184 ie_id = ie[i]; 1185 ie_id = ie[i];
@@ -1189,7 +1190,7 @@ static void b43_write_beacon_template(struct b43_wldev *dev,
1189 /* This is the TIM Information Element */ 1190 /* This is the TIM Information Element */
1190 1191
1191 /* Check whether the ie_len is in the beacon data range. */ 1192 /* Check whether the ie_len is in the beacon data range. */
1192 if (len < ie_len + 2 + i) 1193 if (variable_len < ie_len + 2 + i)
1193 break; 1194 break;
1194 /* A valid TIM is at least 4 bytes long. */ 1195 /* A valid TIM is at least 4 bytes long. */
1195 if (ie_len < 4) 1196 if (ie_len < 4)