Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-users: Re: [Wireshark-users] New dissector: variable length of a fields

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Sun, 16 Feb 2014 12:00:32 -0800
On Feb 15, 2014, at 10:17 PM, Dmitrij K <kdiman@xxxxxxx> wrote:

	...

> Binary datas range from 0-*:  <MISSING>
> ------- Here must be the 'Field magic3: 0x3' but it is not !!! --------
>> Dissector bug, protocol MYPROTO: proto.c:3566: failed assertion "DISSECTOR_ASSERT_NOT_REACHED"

OK, what you're doing wrong is doing

     proto_tree_add_item(my_tree, hf_hdr_magic3, tvb, offset, -1, FALSE); offset += 1;

rather than

     proto_tree_add_item(my_tree, hf_hdr_magic3, tvb, offset, 1, FALSE); offset += 1;

"magic3" is specified as a 1-byte field, so its length must be 1, not -1.