Bug 19688

Summary: Some boundry checking KASSERTS in networking code
Product: Base System Reporter: dgilbert <dgilbert>
Component: kernAssignee: jlemon
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description dgilbert 2000-07-04 04:20:00 UTC
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.
Comment 1 billf 2000-07-04 04:26:20 UTC
On Mon, Jul 03, 2000 at 11:15:11PM -0400, David Gilbert wrote:

> >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)
[...]

I can't tell you misguided or not, I can tell you that it's misindented though :->


-- 
Bill Fumerola - Network Architect / Computer Horizons Corp - CHIMES
e-mail: billf@chimesnet.com / billf@FreeBSD.org
Comment 2 dgilbert 2000-07-04 04:41:42 UTC
>>>>> "Bill" == Bill Fumerola <billf@chimesnet.com> writes:

Bill> On Mon, Jul 03, 2000 at 11:15:11PM -0400, David Gilbert wrote:
>> >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)
Bill> [...]

Bill> I can't tell you misguided or not, I can tell you that it's
Bill> misindented though :->

Are we dealing with a tab-stop differenece here?  I believe that the
code looks the same when I'm looking at it in my editor.

Dave.

-- 
============================================================================
|David Gilbert, Velocet Communications.       | Two things can only be     |
|Mail:       dgilbert@velocet.net             |  equal if and only if they |
|http://www.velocet.net/~dgilbert             |   are precisely opposite.  |
=========================================================GLO================
Comment 3 billf 2000-07-04 04:42:55 UTC
On Mon, Jul 03, 2000 at 11:41:42PM -0400, David Gilbert wrote:

> Bill> I can't tell you misguided or not, I can tell you that it's
> Bill> misindented though :->
> 
> Are we dealing with a tab-stop differenece here?  I believe that the
> code looks the same when I'm looking at it in my editor.

Yes. Look how it is different in the delta, if it was indented the
same the delta would be indented the same way.

style(9) says to match the existing style of the file...

-- 
Bill Fumerola - Network Architect / Computer Horizons Corp - CHIMES
e-mail: billf@chimesnet.com / billf@FreeBSD.org
Comment 4 Sheldon Hearn freebsd_committer freebsd_triage 2000-07-05 11:04:42 UTC
Responsible Changed
From-To: freebsd-bugs->wollman

This is Garrett's baby and he can manage PR's again. :-)
Comment 5 Sheldon Hearn freebsd_committer freebsd_triage 2000-07-05 11:26:27 UTC
Responsible Changed
From-To: wollman->jlemon

Oops, the last time Garrett and I discussed PRs, he asked me not 
to assign them to him.   

Jonathan, could you look at this one?
Comment 6 jlemon freebsd_committer freebsd_triage 2001-06-15 22:23:35 UTC
State Changed
From-To: open->closed

Useful KASSERTS are always welcomed if they provide a benefit. 
However, the file in question has never been used, and is not  
likely to be used in its current form in the near future.