Re: drivers/net/niu.c: possible array overflows

From: David Miller
Date: Mon Oct 15 2007 - 04:36:57 EST


From: Adrian Bunk <bunk@xxxxxxxxxx>
Date: Sun, 14 Oct 2007 19:50:24 +0200

> The Coverity checker spotted the following in drivers/net/niu.c:

Thanks for the report Adrian, I'll fix it like this:

commit 503211a947ab13fb44d920f78f1e19057efc277f
Author: David S. Miller <davem@xxxxxxxxxxxxxxxxxxxx>
Date: Mon Oct 15 01:36:24 2007 -0700

[NIU]: Fix write past end of array in niu_pci_probe_sprom().

Noticed by Coverity checker and reported by Adrian Bunk.

Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>

diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 43bfe7e..54166bd 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -6213,7 +6213,7 @@ static int __devinit niu_pci_probe_sprom(struct niu *np)
val = nr64(ESPC_MOD_STR_LEN);
niudbg(PROBE, "SPROM: MOD_STR_LEN[%llu]\n",
(unsigned long long) val);
- if (val > 8 * 4)
+ if (val >= 8 * 4)
return -EINVAL;

for (i = 0; i < val; i += 4) {
@@ -6229,7 +6229,7 @@ static int __devinit niu_pci_probe_sprom(struct niu *np)
val = nr64(ESPC_BD_MOD_STR_LEN);
niudbg(PROBE, "SPROM: BD_MOD_STR_LEN[%llu]\n",
(unsigned long long) val);
- if (val > 4 * 4)
+ if (val >= 4 * 4)
return -EINVAL;

for (i = 0; i < val; i += 4) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/