tvb_format_text works very well..:-) Thanks, here is a tiny patch for it.
huagang
Guy Harris wrote:
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.
diff -u -r1.2 packet-mysql.c
--- packet-mysql.c 2003/01/20 06:54:52 1.2
+++ packet-mysql.c 2003/01/21 01:26:25
@@ -391,7 +391,7 @@
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, " : %s",
- tvb_memdup(tvb,offset,strlen));
+ tvb_format_text(tvb,offset,strlen));
}
if (tree) {
