Ethereal-dev: Re: [Ethereal-dev] problem in packet-tns

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: Thu, 31 Jan 2002 15:03:43 -0600
On Thu, 31 Jan 2002 14:40:39 Gilbert Ramirez wrote:
> On Thu, 31 Jan 2002 10:50:11 Gilbert Ramirez wrote:
> > 
> > The assert in proto.c happens if length == -1. Note the comment:
> > 
> >     if (length == -1) {
> >         /*
> >          * For FT_NONE or FT_PROTOCOL fields, this means "set the
> >          * length to what remains in the tvbuff"; the assumption
> >          * is that the length can only be determined by dissection,
> >          * so we set it to that value so that, if we throw an
> >          * exception while dissecting, it has what is probably the
> >          * right value.
> >          *
> >          * It's not valid for any other type of field.
> >          */
> >         g_assert(hfinfo->type == FT_PROTOCOL ||
> >              hfinfo->type == FT_NONE);
> >         length = tvb_length_remaining(tvb, start);
> >     }
> > 
> >
> 
> The other side of the coin is that perhaps the assert shouldn't
> blow up on FT_STRING. I'm examining that now.
> 
> Regardless, the return value of tvb_length_remaining() should
> be checked here.

Here's a proposed patch which does just that. It allows
the TNS dissector to use -1 as the length, and the correct length
is retrieved from the tvbuff, or,  in the case of the bad
packet, and exception is thrown.

More dissectors will have to be fixed, however.

--gilbert

Attachment: ensure_length.diff
Description: Binary data