Wireshark-dev: Re: [Wireshark-dev] FT_BYTES hf with len==0
From: Jakub Zawadzki <darkjames-ws@xxxxxxxxxxxx>
Date: Mon, 16 Dec 2013 20:58:28 +0100
Hi,

On Mon, Dec 16, 2013 at 05:48:12PM +0100, Martin Kaiser wrote:
> is it allowed to add an FT_BYTES hf entry with len==0 to the protocol
> tree?
> 
> E.g. 
> 
> proto_tree_add_bytes_format_value(tree, hf_myproto_myval,
>    tvb, offset, 0, NULL, format, ...)
> 
> The idea would be to allow filtering for this element although it has no
> value (it's just there).
> 
> When I do this, I run into an assert in proto_custom_set(),
> 
>        case FT_BYTES:
>                 bytes = (guint8 *)fvalue_get(&finfo->value);
>                ... bytes_to_string(bytes, ...) -> DISSECTOR_ASSERT
> 
> 
> Who's at fault here: proto_custom_set() or the caller?

proto_item_fill_label() allows empty bytes:

5389     case FT_BYTES:
5390     case FT_UINT_BYTES:
5391             bytes = (guint8 *)fvalue_get(&fi->value);
5392             label_fill(label_str, 0, hfinfo,
5393                             (bytes) ? bytes_to_str(bytes, fvalue_length(&fi->value)) : "<MISSING>");
5394             break;

It'd be good to make them consistent, allow empty bytes (+1 from me) or assert in both place.

The check in proto_item_fill_label() is almost from begining (r1979).

Kuba.