netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: bunk@kernel.org
Cc: davem@sunset.davemloft.net, jgarzik@pobox.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: drivers/net/niu.c: possible array overflows
Date: Mon, 15 Oct 2007 01:36:47 -0700 (PDT)	[thread overview]
Message-ID: <20071015.013647.95041541.davem@davemloft.net> (raw)
In-Reply-To: <20071014175024.GH4211@stusta.de>

From: Adrian Bunk <bunk@kernel.org>
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@sunset.davemloft.net>
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@davemloft.net>

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) {

      reply	other threads:[~2007-10-15  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-14 17:50 drivers/net/niu.c: possible array overflows Adrian Bunk
2007-10-15  8:36 ` David Miller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071015.013647.95041541.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=bunk@kernel.org \
    --cc=davem@sunset.davemloft.net \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).