EPL: Reject non-EPL packets at the beginning

If we're going to reject a packet because it's not a valid EPL
packet, do so at the beginning, before setting the column values
and changing the port types and values.
This commit is contained in:
John Thacker 2021-10-29 22:34:48 -04:00
parent 523c4f6434
commit 278ba4157f
1 changed files with 11 additions and 6 deletions

View File

@ -2521,12 +2521,9 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp
if (tvb_reported_length(tvb) < 3)
{
/* Not enough data for an EPL header; don't try to interpret it */
return FALSE;
return 0;
}
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, udpencap ? "POWERLINK/UDP" : "POWERLINK");
/* Get message type */
epl_mtyp = tvb_get_guint8(tvb, EPL_MTYP_OFFSET) & 0x7F;
@ -2536,7 +2533,15 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp
* to dissect it as a normal EPL packet.
*/
if (dissector_try_heuristic(heur_epl_subdissector_list, tvb, pinfo, tree, &hdtbl_entry, &epl_mtyp))
return TRUE;
return tvb_reported_length(tvb);
if (!try_val_to_str(epl_mtyp, mtyp_vals)) {
/* Not an EPL packet */
return 0;
}
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, udpencap ? "POWERLINK/UDP" : "POWERLINK");
/* tap */
/* mi.epl_mtyp = epl_mtyp;
@ -2607,7 +2612,7 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp
break;
default: /* no valid EPL packet */
return FALSE;
return 0;
}
if (tree)