diff mbox

libertas: Read buffer overflow

Message ID 4A7543CC.2010206@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Roel Kluin Aug. 2, 2009, 7:44 a.m. UTC
Check whether index is within bounds before testing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
--
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

Dan Williams Aug. 4, 2009, 3:16 p.m. UTC | #1
On Sun, 2009-08-02 at 09:44 +0200, Roel Kluin wrote:
> Check whether index is within bounds before testing the element.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Acked-by: Dan Williams <dcbw@redhat.com>

> ---
> diff --git a/drivers/net/wireless/libertas/11d.c b/drivers/net/wireless/libertas/11d.c
> index 9a5408e..5c69681 100644
> --- a/drivers/net/wireless/libertas/11d.c
> +++ b/drivers/net/wireless/libertas/11d.c
> @@ -47,7 +47,7 @@ static u8 lbs_region_2_code(u8 *region)
>  {
>  	u8 i;
>  
> -	for (i = 0; region[i] && i < COUNTRY_CODE_LEN; i++)
> +	for (i = 0; i < COUNTRY_CODE_LEN && region[i]; i++)
>  		region[i] = toupper(region[i]);
>  
>  	for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
> --
> 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

--
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/libertas/11d.c b/drivers/net/wireless/libertas/11d.c
index 9a5408e..5c69681 100644
--- a/drivers/net/wireless/libertas/11d.c
+++ b/drivers/net/wireless/libertas/11d.c
@@ -47,7 +47,7 @@  static u8 lbs_region_2_code(u8 *region)
 {
 	u8 i;
 
-	for (i = 0; region[i] && i < COUNTRY_CODE_LEN; i++)
+	for (i = 0; i < COUNTRY_CODE_LEN && region[i]; i++)
 		region[i] = toupper(region[i]);
 
 	for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {