Ethereal-dev: Re: [Ethereal-dev] Updates to spoolss dissector

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Tim Potter <tpot@xxxxxxxxx>
Date: Fri, 4 Jan 2002 17:19:57 +1100
On Fri, Jan 04, 2002 at 12:09:47AM -0600, Gilbert Ramirez wrote:

> > diff -u -r1.2 packet-dcerpc-nt.c
> > --- packet-dcerpc-nt.c	2002/01/03 20:42:40	1.2
> > +++ packet-dcerpc-nt.c	2002/01/04 05:53:16
> > @@ -75,6 +75,11 @@
> >  {
> >  	const guint8 *ptr;
> >  	
> > +	/* The tvb_get_ptr() function fails an assertion if count < -1
> > */
> > +	
> > +	if (count < -1)
> > +		THROW(BoundsError);
> > +
> >  	/* No alignment required */
> 
> Do you really want the dissector to throw a BoundsError? Wouldn't
> it be better to have the tvbuff code throw some kind of InvalidValueError?

I was thinking that a BoundsError is the best exception to throw.  If
the dissector decides it wants some random number of bytes with the high
bit set then it's obviously a malformed frame and ethereal should display
it as such.

> However, if you're going to check the count in the dissector, don't
> you want to complain if count < 0, since dcerpc-nt's idea of a -1
> count is not the same as tvbuff's idea of what -1 means. What about
> the situation where count == 0 ?

You're right - it should really be a < 0 in that if statement instead of
< -1.  I'm not sure what happens with count == 0.  (-:  I suspect any
dissector requesting this will then do a for (i = 0; i < 0; i++) on it
and then throw it away.


Tim.
> 
> --gilbert