Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Work around Coverity CIDs 127102{0, 1}: Confused ...



details:   https://anonhg.NetBSD.org/src/rev/3c5f48beaf1d
branches:  trunk
changeset: 806427:3c5f48beaf1d
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Feb 24 12:57:58 2015 +0000

description:
Work around Coverity CIDs 127102{0,1}: Confused by the comparison
nrates > __arraycount(lq->rs_table), coverity erroneously binds nrates
to the range [0..16), whereas it is really bound to [0..15) by
ni->ni_rates.rs_nrates (IEEE80211_RATE_MAXSIZE). We add an explicit comparison
to unconfuse it that will always succeed.

diffstat:

 sys/dev/pci/if_iwm.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r fd2f1a46800d -r 3c5f48beaf1d sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c      Tue Feb 24 02:26:15 2015 +0000
+++ b/sys/dev/pci/if_iwm.c      Tue Feb 24 12:57:58 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_iwm.c,v 1.13 2015/02/24 02:26:15 nonaka Exp $       */
+/*     $NetBSD: if_iwm.c,v 1.14 2015/02/24 12:57:58 christos Exp $     */
 /*     OpenBSD: if_iwm.c,v 1.18 2015/02/11 01:12:42 brad Exp   */
 
 /*
@@ -105,7 +105,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.13 2015/02/24 02:26:15 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.14 2015/02/24 12:57:58 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -5329,7 +5329,8 @@
        int i, ridx, tab = 0;
        int txant = 0;
 
-       if (nrates > __arraycount(lq->rs_table)) {
+       if (nrates > __arraycount(lq->rs_table) ||
+           nrates > IEEE80211_RATE_MAXSIZE) {
                DPRINTF(("%s: node supports %d rates, driver handles only "
                    "%zu\n", DEVNAME(sc), nrates, __arraycount(lq->rs_table)));
                return;



Home | Main Index | Thread Index | Old Index