On Mon, Jan 20, 2003 at 04:57:58PM -0800, Huagang XIE wrote:
> Thanks! There is still a problem I can not fix..
>
> when I try to use col_append_fstr() to add a string from the packet to
> COL_INFO. That string is at the end of a record(packet) without a "NULL"
> ended, but we know length of the string. The problem is it seems that
> the tvb_memdup(tvb,offset,length) is not working very well, it show more
> bytes (which cross the packet) on the COL_INFO.
Well, it's actually working very well for what it's intended to do - it
allocates a block of memory and copies a specified number of bytes from
the tvbuff to that block.
It is not intended to null-terminate the block of memory, as it's not
necessarily working on a C-language string.
> do you have a good solution to it?
col_append_fstr(pinfo->cinfo, COL_INFO, " : %s",
tvb_format_text(tvb,offset,strlen));
That also handles non-printable characters by escaping them rather than
inserting them directly into the Info column.