aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-epl.c
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2021-10-29 22:34:48 -0400
committerJohn Thacker <johnthacker@gmail.com>2021-10-29 22:38:42 -0400
commit278ba4157f0856e7af0b16257a9d53304393ec65 (patch)
treeda5683c94ab23548e2937b874d6c77c3fa1408fb /epan/dissectors/packet-epl.c
parent523c4f643431be6b873720be14ff9de55146afbd (diff)
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.
Diffstat (limited to 'epan/dissectors/packet-epl.c')
-rw-r--r--epan/dissectors/packet-epl.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c
index 6b0cbfc036..66ce1b2a74 100644
--- a/epan/dissectors/packet-epl.c
+++ b/epan/dissectors/packet-epl.c
@@ -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)