Ethereal-dev: Re: [Ethereal-dev] tvb_strnlen problem

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Fri, 13 Oct 2000 18:13:51 -0700 (PDT)
> This is the broken patch I came up with:

Yes, the problem is that "tvb_strnlen()" is returning the offset of the
'\0', not the length of the string.

The next problem is that "tvb_get_nstringz()" is assuming that it's
returning the offset, rather than the length, so "tvb_get_nstringz()"
should probably do

	stringlen = tvb_strnlen(tvb, abs_offset, limit);

	/* If NUL wasn't found, copy the data and return -1 */
	if (stringlen == -1) {
		tvb_memcpy(tvb, buffer, abs_offset, limit);
		return -1;
	}

	/* Copy the string to buffer */
	tvb_memcpy(tvb, buffer, abs_offset, stringlen + 1);
	return stringlen;

So try changing "tvb_get_nstringz()" as per the above, and see if that
works.