kern/181821: Use unsigned type when indexing into mfchashtbl

Sven-Thorsten Dietrich sven at inter-yacht.com
Wed Sep 4 19:30:00 UTC 2013


>Number:         181821
>Category:       kern
>Synopsis:       Use unsigned type when indexing into mfchashtbl
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 04 19:30:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Sven-Thorsten Dietrich
>Release:        HEAD
>Organization:
Vyatta
>Environment:
>Description:
Several instances of indexing into hash table using int type.
Should always index into hash table using unsigned.
>How-To-Repeat:

>Fix:
See patch

Patch attached with submission follows:

Use unsigned type when indexing into mfchashtbl.
Eliminate rollover problems and consequent out-of-bounds indexes
for size of mfchashtbl > MAXINT.

Signed-off-by: Sven-Thorsten Dietrich <sven at vyatta.com>

Index: netinet/ip_mroute.c
===================================================================
--- netinet/ip_mroute.c	(revision 255189)
+++ netinet/ip_mroute.c	(working copy)
@@ -609,7 +608,7 @@
 if_detached_event(void *arg __unused, struct ifnet *ifp)
 {
     vifi_t vifi;
-    int i;
+    u_long i;
 
     MROUTER_LOCK();
 
@@ -705,7 +704,7 @@
 X_ip_mrouter_done(void)
 {
     vifi_t vifi;
-    int i;
+    u_long i;
     struct ifnet *ifp;
     struct ifreq ifr;
 
@@ -803,7 +802,7 @@
 int
 set_api_config(uint32_t *apival)
 {
-    int i;
+    u_long i;
 
     /*
      * We can set the API capabilities only if it is the first operation
@@ -1439,7 +1438,7 @@
 static void
 expire_upcalls(void *arg)
 {
-    int i;
+    u_long i;
 
     CURVNET_SET((struct vnet *) arg);
 


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list