diff options
author | Uli Heilmeier <uh@heilmeier.eu> | 2021-04-20 22:47:43 +0200 |
---|---|---|
committer | Uli Heilmeier <uh@heilmeier.eu> | 2021-04-26 14:11:04 +0000 |
commit | ab13858b7fd6f625c847f95b2adaab841678471b (patch) | |
tree | 0bc1a617ead03ec0a4e35364b82b67514b191f10 | |
parent | aa169ab2243607a6db9b3adca65e918a2c8ca60b (diff) |
PTP: Check for enough bytes
Make sure we have enough bytes for Length and Type fields before we read
from tvb.
Using existing msg_len for the checks.
Closes: wireshark/wireshark#17355
(cherry picked from commit fd14396972733e8e2e1023150f628e3aa7370b18)
-rw-r--r-- | epan/dissectors/packet-ptp.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/epan/dissectors/packet-ptp.c b/epan/dissectors/packet-ptp.c index 3121c2ec94..3cc5e208b3 100644 --- a/epan/dissectors/packet-ptp.c +++ b/epan/dissectors/packet-ptp.c @@ -2562,7 +2562,6 @@ dissect_ptp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean ptp col_add_str(pinfo->cinfo, COL_INFO, val_to_str_ext(ptp_v2_messageid, &ptp_v2_messageid_vals_ext, "Unknown PTP Message (%u)")); if (ptp_v2_messageid == PTP_V2_SIGNALLING_MESSAGE) { - guint proto_len; guint32 tlv_offset; guint16 tlv_type; guint32 org_id; @@ -2570,10 +2569,9 @@ dissect_ptp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean ptp guint16 tlv_length; guint16 wr_messageId; - proto_len = tvb_reported_length(tvb); tlv_offset = PTP_V2_SIG_TLV_START; - while (tlv_offset < proto_len) + while (tlv_offset + PTP_V2_SIG_TLV_LENGTH_LEN + PTP_V2_SIG_TLV_TYPE_LEN <= msg_len) { tlv_length = tvb_get_ntohs(tvb, tlv_offset + PTP_V2_SIG_TLV_LENGTH_OFFSET); tlv_type = tvb_get_ntohs(tvb, tlv_offset + PTP_V2_SIG_TLV_TYPE_OFFSET); |