From owner-freebsd-bugs Mon Jul 3 20:20: 5 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id C979337BAA2 for ; Mon, 3 Jul 2000 20:20:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id UAA98640; Mon, 3 Jul 2000 20:20:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from sabre.velocet.net (sabre.velocet.net [198.96.118.66]) by hub.freebsd.org (Postfix) with ESMTP id 27C9137C2D6 for ; Mon, 3 Jul 2000 20:16:03 -0700 (PDT) (envelope-from dgilbert@office.tor.velocet.net) Received: from office.tor.velocet.net (trooper.velocet.net [216.126.82.226]) by sabre.velocet.net (Postfix) with ESMTP id 6F20A137F06 for ; Mon, 3 Jul 2000 23:16:01 -0400 (EDT) Received: (from dgilbert@localhost) by office.tor.velocet.net (8.9.3/8.9.3) id XAA36155; Mon, 3 Jul 2000 23:15:11 -0400 (EDT) (envelope-from dgilbert) Message-Id: <200007040315.XAA36155@office.tor.velocet.net> Date: Mon, 3 Jul 2000 23:15:11 -0400 (EDT) From: David Gilbert Reply-To: dgilbert@velocet.ca To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/19688: Adding some KASSERTS v1 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 19688 >Category: kern >Synopsis: Some boundry checking KASSERTS in networking code >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Jul 03 20:20:00 PDT 2000 >Closed-Date: >Last-Modified: >Originator: David Gilbert >Release: FreeBSD 4.0-STABLE i386 >Organization: Velocet Communications >Environment: I'm running this against 4.0-STABLE, but this can probably apply better debugging to several branches. >Description: I'm trying to track down other bugs, so I'm going through networking file-by-file looking for possibly array overflows (which I belive my problem to be). Anyways, I felt that it might be useful if I contributed some of my KASSERT()'s back to the tree. Someone can slap my fingers if this is misguided. >How-To-Repeat: heh. >Fix: --- /sys/net/hostcache.c Fri Aug 27 20:48:15 1999 +++ hostcache.c Mon Jul 3 23:08:34 2000 @@ -55,6 +55,8 @@ struct hchead *heads; u_long nelem; + KASSERT(af >= 0 && af < AF_MAX, ("hc_init: af=%d out of range", af)); + hct = &hctable[af]; nelem = init_nelem; if (hct->hct_nentries) @@ -86,6 +88,9 @@ struct hctable *hct; int s; + KASSERT(sa->sa_family >=0 && sa->sa_family < AF_MAX, + ("hc_get: sa_family=%d out o frange", sa->sa_family)); + hct = &hctable[sa->sa_family]; if (hct->hct_nentries == 0) return 0; @@ -150,6 +155,10 @@ u_long hash; int s; + KASSERT(hc->hc_host->sa_family >=0 && hc->hc_host->sa_family < AF_MAX, + ("hc_insert: sa_family=%d out of range", + hc->hc_host->sa_family)); + hct = &hctable[hc->hc_host->sa_family]; hash = hct->hct_cb->hccb_hash(hc->hc_host, hct->hct_nentries); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message