* [PATCH 2/2] cosa.c : Array index 'i' is used before limits check.
@ 2015-02-24 19:52 Ameen Ali
2015-02-24 19:57 ` Sergei Shtylyov
0 siblings, 1 reply; 4+ messages in thread
From: Ameen Ali @ 2015-02-24 19:52 UTC (permalink / raw)
To: kas; +Cc: netdev, linux-kernel, Ameen Ali, Ameen Ali
avoid out-of-bounds-read by checking count before indexing.
Signed-off-by: Ameen Ali <Ameenali023@gmail.com>
---
drivers/net/wan/cosa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 83c39e2..5252e21 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -376,7 +376,7 @@ static int __init cosa_init(void)
}
for (i=0; i<MAX_CARDS; i++)
cosa_cards[i].num = -1;
- for (i=0; io[i] != 0 && i < MAX_CARDS; i++)
+ for (i=0; (i < MAX_CARDS) && (io[i] != 0) ; i++)
cosa_probe(io[i], irq[i], dma[i]);
if (!nr_cards) {
pr_warn("no devices found\n");
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] cosa.c : Array index 'i' is used before limits check.
2015-02-24 19:52 [PATCH 2/2] cosa.c : Array index 'i' is used before limits check Ameen Ali
@ 2015-02-24 19:57 ` Sergei Shtylyov
2015-03-02 13:06 ` Jan Kasprzak
0 siblings, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2015-02-24 19:57 UTC (permalink / raw)
To: Ameen Ali, kas; +Cc: netdev, linux-kernel
Hello.
On 02/24/2015 10:52 PM, Ameen Ali wrote:
> avoid out-of-bounds-read by checking count before indexing.
> Signed-off-by: Ameen Ali <Ameenali023@gmail.com>
> ---
> drivers/net/wan/cosa.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
> index 83c39e2..5252e21 100644
> --- a/drivers/net/wan/cosa.c
> +++ b/drivers/net/wan/cosa.c
> @@ -376,7 +376,7 @@ static int __init cosa_init(void)
> }
> for (i=0; i<MAX_CARDS; i++)
> cosa_cards[i].num = -1;
> - for (i=0; io[i] != 0 && i < MAX_CARDS; i++)
> + for (i=0; (i < MAX_CARDS) && (io[i] != 0) ; i++)
Parens you've added aren't necessary.
I suggest to add spaces after and before = in the first expression.
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] cosa.c : Array index 'i' is used before limits check.
2015-02-24 19:57 ` Sergei Shtylyov
@ 2015-03-02 13:06 ` Jan Kasprzak
2015-03-02 14:16 ` Sergei Shtylyov
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kasprzak @ 2015-03-02 13:06 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: Ameen Ali, netdev, linux-kernel
Sergei Shtylyov wrote:
: Hello.
:
: On 02/24/2015 10:52 PM, Ameen Ali wrote:
:
: >avoid out-of-bounds-read by checking count before indexing.
:
: >Signed-off-by: Ameen Ali <Ameenali023@gmail.com>
: >---
: > drivers/net/wan/cosa.c | 2 +-
: > 1 file changed, 1 insertion(+), 1 deletion(-)
:
: >diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
: >index 83c39e2..5252e21 100644
: >--- a/drivers/net/wan/cosa.c
: >+++ b/drivers/net/wan/cosa.c
: >@@ -376,7 +376,7 @@ static int __init cosa_init(void)
: > }
: > for (i=0; i<MAX_CARDS; i++)
: > cosa_cards[i].num = -1;
: >- for (i=0; io[i] != 0 && i < MAX_CARDS; i++)
: >+ for (i=0; (i < MAX_CARDS) && (io[i] != 0) ; i++)
:
: Parens you've added aren't necessary.
Yes, but I am OK with both variants.
: I suggest to add spaces after and before = in the first expression.
In that case, also the upper for() cycle should be modified
to match this. I don't think this is necessary.
-Yenya
--
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| New GPG 4096R/A45477D5 -- see http://www.fi.muni.cz/~kas/pgp-rollover.txt |
| http://www.fi.muni.cz/~kas/ Journal: http://www.fi.muni.cz/~kas/blog/ |
||| "New and improved" is only really improved if it also takes backwards |||
||| compatibility into account, rather than saying "now everybody must do |||
||| things the new and improved - and different - way" --Linus Torvalds |||
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] cosa.c : Array index 'i' is used before limits check.
2015-03-02 13:06 ` Jan Kasprzak
@ 2015-03-02 14:16 ` Sergei Shtylyov
0 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-03-02 14:16 UTC (permalink / raw)
To: Jan Kasprzak; +Cc: Ameen Ali, netdev, linux-kernel
Hello.
On 3/2/2015 4:06 PM, Jan Kasprzak wrote:
> : >avoid out-of-bounds-read by checking count before indexing.
> :
> : >Signed-off-by: Ameen Ali <Ameenali023@gmail.com>
> : >---
> : > drivers/net/wan/cosa.c | 2 +-
> : > 1 file changed, 1 insertion(+), 1 deletion(-)
> :
> : >diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
> : >index 83c39e2..5252e21 100644
> : >--- a/drivers/net/wan/cosa.c
> : >+++ b/drivers/net/wan/cosa.c
> : >@@ -376,7 +376,7 @@ static int __init cosa_init(void)
> : > }
> : > for (i=0; i<MAX_CARDS; i++)
> : > cosa_cards[i].num = -1;
> : >- for (i=0; io[i] != 0 && i < MAX_CARDS; i++)
> : >+ for (i=0; (i < MAX_CARDS) && (io[i] != 0) ; i++)
> : Parens you've added aren't necessary.
> Yes, but I am OK with both variants.
Anyway, space before ; should be removed (just noticed).
> : I suggest to add spaces after and before = in the first expression.
> In that case, also the upper for() cycle should be modified
> to match this. I don't think this is necessary.
As long as it doesn't cause complaints from scripts/checkpatch.pl...
> -Yenya
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-02 14:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-24 19:52 [PATCH 2/2] cosa.c : Array index 'i' is used before limits check Ameen Ali
2015-02-24 19:57 ` Sergei Shtylyov
2015-03-02 13:06 ` Jan Kasprzak
2015-03-02 14:16 ` Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).