aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValentin Vidic <Valentin.Vidic@CARNet.hr>2018-02-19 12:10:03 +0100
committerAnders Broman <a.broman58@gmail.com>2018-02-19 15:48:56 +0000
commit70608effe4d23bb5f05dc783b21c1ab9d2e5aa66 (patch)
tree6dba8dbfa05835baadcbd0265a2889528924edd4
parent8da569b6ad5beb9fa8c6aa49279e8a805ffbdfda (diff)
TWAMP: Handle short TWAMP-Test packets
Requests packets have a minimum length of 14 bytes and only responses have additional 27 bytes of fields. Without this patch short packets generate an exception and get reported as malformed. Change-Id: If75fa5556059b13f40fc49273edcbd32508fa0fc Reviewed-on: https://code.wireshark.org/review/25897 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/dissectors/packet-twamp.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/epan/dissectors/packet-twamp.c b/epan/dissectors/packet-twamp.c
index cec61bcd45..9497f447ad 100644
--- a/epan/dissectors/packet-twamp.c
+++ b/epan/dissectors/packet-twamp.c
@@ -553,23 +553,26 @@ dissect_twamp_test(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
proto_tree_add_bitmask(twamp_tree, tvb, offset, hf_twamp_error_estimate, ett_twamp_error_estimate, twamp_error_estimate_flags, ENC_BIG_ENDIAN);
offset += 2;
- proto_tree_add_item (twamp_tree, hf_twamp_mbz1, tvb, offset, 2, ENC_BIG_ENDIAN);
- offset += 2;
- proto_tree_add_item(twamp_tree, hf_twamp_receive_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
- offset += 8;
+ /* Responder sends TWAMP-Test packets with additional fields */
+ if (tvb_reported_length(tvb) - offset >= 27) {
+ proto_tree_add_item (twamp_tree, hf_twamp_mbz1, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+ proto_tree_add_item(twamp_tree, hf_twamp_receive_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
+ offset += 8;
- proto_tree_add_item (twamp_tree, hf_twamp_sender_seq_number, tvb, offset, 4, ENC_BIG_ENDIAN);
- offset += 4;
+ proto_tree_add_item (twamp_tree, hf_twamp_sender_seq_number, tvb, offset, 4, ENC_BIG_ENDIAN);
+ offset += 4;
- proto_tree_add_item(twamp_tree, hf_twamp_sender_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
- offset += 8;
+ proto_tree_add_item(twamp_tree, hf_twamp_sender_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
+ offset += 8;
- proto_tree_add_item (twamp_tree, hf_twamp_sender_error_estimate, tvb, offset, 2, ENC_BIG_ENDIAN);
- offset += 2;
- proto_tree_add_item (twamp_tree, hf_twamp_mbz2, tvb, offset, 2, ENC_BIG_ENDIAN);
- offset += 2;
- proto_tree_add_item (twamp_tree, hf_twamp_sender_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset += 1;
+ proto_tree_add_item (twamp_tree, hf_twamp_sender_error_estimate, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+ proto_tree_add_item (twamp_tree, hf_twamp_mbz2, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+ proto_tree_add_item (twamp_tree, hf_twamp_sender_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+ }
padding = tvb_reported_length(tvb) - offset;
if (padding > 0) {