Wireshark mailing list archives
Re: how to handle dissecting length encoded strings
From: Jakub Zawadzki <darkjames () darkjames ath cx>
Date: Mon, 14 Mar 2011 18:56:10 +0100
On Mon, Mar 14, 2011 at 09:51:06AM -0400, Fulko Hew wrote:
I'm looking into a bug in a dissector, and I don't see what the 'right way' to fix it would be. Here's the existing code snippet: static int dissect_octet_string(tvbuff_t *tvb, proto_tree *tree, int offset, char flags) { guint32 n_oct, p_noct; char context[1024]; NORLEL(flags, n_oct, tvb, offset); p_noct = PADDING(n_oct); if (n_oct >= 1024) THROW(ReportedBoundsError); if (n_oct > 0) count = tvb_get_nstringz(tvb, offset + 4, n_oct, context); context[n_oct]='\0'; proto_tree_add_uint(tree, hf_ostring_len, tvb, offset, 4, n_oct); proto_tree_add_string(tree, hf_ostring, tvb, offset + 4, n_oct, context); return p_noct + 4; } Comments anyone?
hf of type FT_UINT_STRING wouldn't work for you? FT_UINT_STRING A counted string of characters, consisting of a count (represented as an integral value, of width given in the proto_tree_add_item() call) followed immediately by that number of characters 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:
- how to handle dissecting length encoded strings Fulko Hew (Mar 14)
- Re: how to handle dissecting length encoded strings Chris Maynard (Mar 14)
- Re: how to handle dissecting length encoded strings Chris Maynard (Mar 14)
- Re: how to handle dissecting length encoded strings Fulko Hew (Mar 14)
- Re: how to handle dissecting length encoded strings Chris Maynard (Mar 14)
- Re: how to handle dissecting length encoded strings Jakub Zawadzki (Mar 14)
- Re: how to handle dissecting length encoded strings Chris Maynard (Mar 14)
- Re: how to handle dissecting length encoded strings Chris Maynard (Mar 14)