LLDP: Fix malformed packets when EndOfLLDPDU TLV missing

The End of LLDPDU TLV is optional, should not as malformed even if missing.
Resolve it by checking whether the total length of each TLV reaches the total length of TVB.
Close #18029
This commit is contained in:
easonweii 2022-04-26 10:50:05 +08:00 committed by A Wireshark GitLab Utility
parent 90cc7cadf7
commit b72b4cf512
1 changed files with 6 additions and 6 deletions

View File

@ -1795,7 +1795,7 @@ dissect_lldp_time_to_live(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
return offset;
}
/* Dissect End of LLDPDU TLV (Mandatory) */
/* Dissect End of LLDPDU TLV */
static gint32
dissect_lldp_end_of_lldpdu(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint32 offset)
{
@ -4624,7 +4624,7 @@ dissect_lldp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
gint32 rtnValue = 0;
guint16 tempShort;
guint8 tlvType;
gboolean reachedEnd = FALSE;
guint32 tvbLen;
profinet_lldp_column_info *pn_lldp_column_info = NULL;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "LLDP");
@ -4676,9 +4676,9 @@ dissect_lldp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
offset += rtnValue;
/* Dissect optional tlv's until end-of-lldpdu is reached */
while (!reachedEnd)
tvbLen = tvb_captured_length(tvb);
/* Dissect optional tlv info that contained in data packets */
while (offset < tvbLen)
{
tempShort = tvb_get_ntohs(tvb, offset);
tlvType = TLV_TYPE(tempShort);
@ -4735,8 +4735,8 @@ dissect_lldp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
}
if (rtnValue < 0) {
reachedEnd = TRUE;
set_actual_length(tvb, offset + rtnValue);
break;
}
else
offset += rtnValue;