From 15f52841ca14ca8f45c9325ec8898b74ed34db60 Mon Sep 17 00:00:00 2001 From: Uli Heilmeier Date: Wed, 28 Oct 2020 21:01:47 +0000 Subject: [PATCH] RTCP: Extended Reports: check for padding Check if padding flag is set and alter length accordingly. Display rtcp.xr.bl the same way as rtcp.length. Fixes: wireshark/wireshark#16933 (cherry picked from commit e07bb433b2d86b17d014ad3a2178dfdb910b490b) --- epan/dissectors/packet-rtcp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/epan/dissectors/packet-rtcp.c b/epan/dissectors/packet-rtcp.c index d7463e36e2..914e0a3481 100644 --- a/epan/dissectors/packet-rtcp.c +++ b/epan/dissectors/packet-rtcp.c @@ -3161,6 +3161,7 @@ static gboolean validate_xr_block_length(tvbuff_t *tvb, packet_info *pinfo, int proto_item *ti; ti = proto_tree_add_uint(tree, hf_rtcp_xr_block_length, tvb, offset, 2, block_len); + proto_item_append_text(ti, " (%u bytes)", (block_len)*4); switch (block_type) { case RTCP_XR_REF_TIME: if (block_len != 2) @@ -3190,7 +3191,7 @@ static gboolean validate_xr_block_length(tvbuff_t *tvb, packet_info *pinfo, int } static int -dissect_rtcp_xr(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, gint packet_len) +dissect_rtcp_xr(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, unsigned int padding, gint packet_len) { guint block_num; @@ -3200,6 +3201,13 @@ dissect_rtcp_xr(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, return offset + packet_len; } + if (padding) { + /* If there's padding present, we have to remove that from the data part + * The last octet of the packet contains the length of the padding + */ + packet_len -= tvb_get_guint8(tvb, offset + packet_len - 1); + } + /* SSRC */ proto_tree_add_item( tree, hf_rtcp_ssrc_sender, tvb, offset, 4, ENC_BIG_ENDIAN ); offset += 4; @@ -4456,7 +4464,7 @@ dissect_rtcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U offset++; /* Packet length in 32 bit words MINUS one, 16 bits */ offset = dissect_rtcp_length_field(rtcp_tree, tvb, offset); - offset = dissect_rtcp_xr( tvb, pinfo, offset, rtcp_tree, packet_length - 4 ); + offset = dissect_rtcp_xr( tvb, pinfo, offset, rtcp_tree, padding_set, packet_length - 4 ); break; case RTCP_AVB: /* Subtype, 5 bits */