proto: ensure that length is set for proto_tree_add_item_new_ret_length

A user reported that the TNS dissector would show "Malformed Packet" in
the Info column in Qt. The actual packet details and Expert Info dialog
however had no trace of the issue.

It turns out that proto_tree_add_item_new_ret_length did not correctly
set the length. Test case (based on pcap from SampleCaptures wiki):

    tshark -r TNS_Oracle1.pcap -w 19.pcap -Y frame.number==19
    tshark -r 19.pcap -Y tcp

Change-Id: I82cb1ccbc7c3b33d2bcdb22f89a1754c1a4575e7
Fixes: v2.1.0rc0-1394-gc67c6e8f30 ("Add routines to add an item and return the item's real length.")
Reviewed-on: https://code.wireshark.org/review/20098
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Peter Wu 2017-02-14 10:05:01 +01:00 committed by Michael Mann
parent 64d0133e88
commit fcc9cf2e45
1 changed files with 8 additions and 1 deletions

View File

@ -2633,7 +2633,14 @@ proto_tree_add_item_new_ret_length(proto_tree *tree, header_field_info *hfinfo,
return NULL;
}
TRY_TO_FAKE_THIS_ITEM(tree, hfinfo->id, hfinfo);
TRY_TO_FAKE_THIS_ITEM_OR_FREE(tree, hfinfo->id, hfinfo, {
/*
* Even if the tree item is not referenced (and thus faked),
* the caller must still be informed of the actual length.
*/
*lenretval = get_full_length(hfinfo, tvb, start, length,
item_length, encoding);
});
new_fi = new_field_info(tree, hfinfo, tvb, start, item_length);