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: Gilbert Ramirez <gram@xxxxxxxxxxxxxxx>
Date: Fri, 4 Jan 2002 00:09:47 -0600
On Fri, 04 Jan 2002 00:05:43 Tim Potter wrote:
> Hello again.  This patch fixes some crash bugs in the spoolss dissector
> and adds a few more random things.
> 
> 
> Tim.
> 
> 	- functions that return a range of uint8,16,32 bytes have a 
> 	  check so as not to pass a negative count value to tvb_get_ptr()

> 
> ? diff.out
> Index: packet-dcerpc-nt.c
> ===================================================================
> RCS file: /cvsroot/ethereal/packet-dcerpc-nt.c,v
> retrieving revision 1.2
> 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?

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 ?

--gilbert