Wireshark-commits: [Wireshark-commits] master 281dd22: tvb: gracefully handle reading 0 bytes from

From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Thu, 27 Sep 2018 04:33:01 +0000
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=281dd22da96daa105580bf25f064ddfdc99a719d
Submitter: "Anders Broman <a.broman58@xxxxxxxxx>"
Changed: branch: master
Repository: wireshark

Commits:

281dd22 by Peter Wu (peter@xxxxxxxxxxxxx):

    tvb: gracefully handle reading 0 bytes from an empty buffer
    
    proto_tree_add_item with a zero length argument could end up calling
    tvb_get_ptr to retrieve the (empty) backing buffer. This empty tvb was
    possibly the result of bad reassembly, but let's gracefully handle it to
    avoid a dissector exception.
    
    Call trace for the original exception (only present on the first pass):
    
        proto_report_dissector_bug (format=0x7ffffffecea0 "") at epan/proto.c:1368
        ensure_contiguous_no_exception (tvb=0x6060001a5460, offset=0, length=0, pexception=0x7ffffffed060) at epan/tvbuff.c:775
        ensure_contiguous (tvb=0x6060001a5460, offset=0, length=0) at epan/tvbuff.c:785
        tvb_get_ptr (tvb=0x6060001a5460, offset=0, length=0) at epan/tvbuff.c:906
        subset_get_ptr (tvb=0x607000194b90, abs_offset=0, abs_length=0) at epan/tvbuff_subset.c:58
        ensure_contiguous_no_exception (tvb=0x607000194b90, offset=0, length=0, pexception=0x7ffffffed3c0) at epan/tvbuff.c:773
        ensure_contiguous (tvb=0x607000194b90, offset=0, length=0) at epan/tvbuff.c:785
        tvb_get_ptr (tvb=0x607000194b90, offset=0, length=0) at epan/tvbuff.c:906
        proto_tree_set_bytes_tvb (fi=0x608000535ca0, tvb=0x607000194b90, offset=0, length=0) at epan/proto.c:3862
        proto_tree_new_item (new_fi=0x608000535ca0, tree=0x604000543150, tvb=0x607000194b90, start=0, length=0, encoding=0) at epan/proto.c:2318
        proto_tree_add_item_new (tree=0x604000543150, hfinfo=0x7ffff30e91f8, tvb=0x607000194b90, start=0, length=0, encoding=0) at epan/proto.c:3381
        proto_tree_add_item (tree=0x604000543150, hfindex=65120, tvb=0x607000194b90, start=0, length=0, encoding=0) at epan/proto.c:3391
        dissect_body_data (tree=0x604000543150, pinfo=0x614000000a58, tvb=0x607000194b90, start=0, length=0, encoding=0) at epan/dissectors/packet-http2.c:1974
    
    Change-Id: Icfae83d61ddcc9e26f16eab7f6e0e84e2f0d73ac
    Reviewed-on: https://code.wireshark.org/review/29851
    Petri-Dish: Peter Wu <peter@xxxxxxxxxxxxx>
    Tested-by: Petri Dish Buildbot
    Reviewed-by: Anders Broman <a.broman58@xxxxxxxxx>
    

Actions performed:

    from  123bcb0   Make systemd journal entries events.
     add  281dd22   tvb: gracefully handle reading 0 bytes from an empty buffer


Summary of changes:
 epan/tvbtest.c | 25 ++++++++++++++++++-------
 epan/tvbuff.c  | 10 +++++++++-
 2 files changed, 27 insertions(+), 8 deletions(-)