Wireshark mailing list archives

Re: How to get UDP port numbers in sub-dissector


From: darkjames-ws () darkjames pl
Date: Tue, 24 May 2011 21:06:18 +0200

On Tue, May 24, 2011 at 02:50:35PM -0400, eymanm wrote:
    col_add_fstr(pinfo->cinfo, COL_INFO, "Source: %s", pinfo->srcport);

When I run, it puts "[Dissector bug, protocol XXX: STATUS_ACCESS_VIOLATION:
dissector accessed and invalid memory address]" in the Info column.

What am I doing wrong?

pinfo->srcport is number so you MUST not use %s (which is for string)
Use %u instead, i.e:
    col_add_fstr(pinfo->cinfo, COL_INFO, "Source: %u", pinfo->srcport);

You can read more about formating string on man 3 printf, html version:
http://linux.die.net/man/3/printf

Cheers.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: