Commit 9799218a authored by David S. Miller's avatar David S. Miller

Revert "libertas: Read buffer overflow"

This reverts commit 57921c31.

On request from John Linville:

	It has been shown to create a new problem.  There is work
	towards a solution to that one, but it isn't a simple
	clean-up.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e9d126cd
/* Copyright (C) 2006, Red Hat, Inc. */ /* Copyright (C) 2006, Red Hat, Inc. */
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/ieee80211.h> #include <linux/ieee80211.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
...@@ -44,21 +43,21 @@ static int get_common_rates(struct lbs_private *priv, ...@@ -44,21 +43,21 @@ static int get_common_rates(struct lbs_private *priv,
u16 *rates_size) u16 *rates_size)
{ {
u8 *card_rates = lbs_bg_rates; u8 *card_rates = lbs_bg_rates;
size_t num_card_rates = sizeof(lbs_bg_rates);
int ret = 0, i, j; int ret = 0, i, j;
u8 tmp[(ARRAY_SIZE(lbs_bg_rates) - 1) * (*rates_size - 1)]; u8 tmp[30];
size_t tmp_size = 0; size_t tmp_size = 0;
/* For each rate in card_rates that exists in rate1, copy to tmp */ /* For each rate in card_rates that exists in rate1, copy to tmp */
for (i = 0; i < ARRAY_SIZE(lbs_bg_rates) && card_rates[i]; i++) { for (i = 0; card_rates[i] && (i < num_card_rates); i++) {
for (j = 0; j < *rates_size && rates[j]; j++) { for (j = 0; rates[j] && (j < *rates_size); j++) {
if (rates[j] == card_rates[i]) if (rates[j] == card_rates[i])
tmp[tmp_size++] = card_rates[i]; tmp[tmp_size++] = card_rates[i];
} }
} }
lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size); lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size);
lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, num_card_rates);
ARRAY_SIZE(lbs_bg_rates));
lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size);
lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate);
...@@ -70,7 +69,10 @@ static int get_common_rates(struct lbs_private *priv, ...@@ -70,7 +69,10 @@ static int get_common_rates(struct lbs_private *priv,
lbs_pr_alert("Previously set fixed data rate %#x isn't " lbs_pr_alert("Previously set fixed data rate %#x isn't "
"compatible with the network.\n", priv->cur_rate); "compatible with the network.\n", priv->cur_rate);
ret = -1; ret = -1;
goto done;
} }
ret = 0;
done: done:
memset(rates, 0, *rates_size); memset(rates, 0, *rates_size);
*rates_size = min_t(int, tmp_size, *rates_size); *rates_size = min_t(int, tmp_size, *rates_size);
...@@ -320,7 +322,7 @@ static int lbs_associate(struct lbs_private *priv, ...@@ -320,7 +322,7 @@ static int lbs_associate(struct lbs_private *priv,
rates = (struct mrvl_ie_rates_param_set *) pos; rates = (struct mrvl_ie_rates_param_set *) pos;
rates->header.type = cpu_to_le16(TLV_TYPE_RATES); rates->header.type = cpu_to_le16(TLV_TYPE_RATES);
memcpy(&rates->rates, &bss->rates, MAX_RATES); memcpy(&rates->rates, &bss->rates, MAX_RATES);
tmplen = min_t(u16, ARRAY_SIZE(rates->rates), MAX_RATES); tmplen = MAX_RATES;
if (get_common_rates(priv, rates->rates, &tmplen)) { if (get_common_rates(priv, rates->rates, &tmplen)) {
ret = -1; ret = -1;
goto done; goto done;
...@@ -596,7 +598,7 @@ static int lbs_adhoc_join(struct lbs_private *priv, ...@@ -596,7 +598,7 @@ static int lbs_adhoc_join(struct lbs_private *priv,
/* Copy Data rates from the rates recorded in scan response */ /* Copy Data rates from the rates recorded in scan response */
memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates)); memset(cmd.bss.rates, 0, sizeof(cmd.bss.rates));
ratesize = min_t(u16, ARRAY_SIZE(cmd.bss.rates), MAX_RATES); ratesize = min_t(u16, sizeof(cmd.bss.rates), MAX_RATES);
memcpy(cmd.bss.rates, bss->rates, ratesize); memcpy(cmd.bss.rates, bss->rates, ratesize);
if (get_common_rates(priv, cmd.bss.rates, &ratesize)) { if (get_common_rates(priv, cmd.bss.rates, &ratesize)) {
lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n"); lbs_deb_join("ADHOC_JOIN: get_common_rates returned error.\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment