diff mbox

ipw2x00: Write outside array bounds

Message ID 1248660620.3747.102.camel@debian (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Zhu Yi July 27, 2009, 2:10 a.m. UTC
On Sun, 2009-07-26 at 05:48 +0800, Roel Kluin wrote:
> channel_index loops up to IPW_SCAN_CHANNELS, but is used after being
> incremented. This might be able to access 1 past the end of the array
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Thanks. Do you think below patch is better?

Thanks,
-yi



> ---
> diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
> index 44c29b3..d1c9d6d 100644
> --- a/drivers/net/wireless/ipw2x00/ipw2200.c
> +++ b/drivers/net/wireless/ipw2x00/ipw2200.c
> @@ -6249,7 +6249,10 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
>  
>  				channels[channel - 1] = 1;
>  				priv->speed_scan_pos++;
> -				channel_index++;
> +
> +				if (++channel_index >= IPW_SCAN_CHANNELS)
> +					break;
> +
>  				scan->channels_list[channel_index] = channel;
>  				index =
>  				    ieee80211_channel_to_index(priv->ieee, channel);

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

John W. Linville Aug. 3, 2009, 7:51 p.m. UTC | #1
On Mon, Jul 27, 2009 at 10:10:20AM +0800, Zhu Yi wrote:
> On Sun, 2009-07-26 at 05:48 +0800, Roel Kluin wrote:
> > channel_index loops up to IPW_SCAN_CHANNELS, but is used after being
> > incremented. This might be able to access 1 past the end of the array
> > 
> > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> 
> Thanks. Do you think below patch is better?

Didn't see an answer here...which patch do we want?

John
Zhu Yi Aug. 4, 2009, 12:35 a.m. UTC | #2
On Tue, 2009-08-04 at 03:51 +0800, John W. Linville wrote:
> On Mon, Jul 27, 2009 at 10:10:20AM +0800, Zhu Yi wrote:
> > On Sun, 2009-07-26 at 05:48 +0800, Roel Kluin wrote:
> > > channel_index loops up to IPW_SCAN_CHANNELS, but is used after being
> > > incremented. This might be able to access 1 past the end of the array
> > > 
> > > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> > 
> > Thanks. Do you think below patch is better?
> 
> Didn't see an answer here...which patch do we want?

Please apply mine.

Thanks,
-yi

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 2dc1cdb..07f171c 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -6226,7 +6226,7 @@  static void ipw_add_scan_channels(struct ipw_priv *priv,
 			};
 
 			u8 channel;
-			while (channel_index < IPW_SCAN_CHANNELS) {
+			while (channel_index < IPW_SCAN_CHANNELS - 1) {
 				channel =
 				    priv->speed_scan[priv->speed_scan_pos];
 				if (channel == 0) {