aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-rx.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2007-04-02 08:25:43 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2007-04-02 08:25:43 +0000
commita5f4e7b85a035b234ca06b0c88ee89eda76d6524 (patch)
tree4e8a5bc978e41a10fa5415833eb6243fe1bbc4f2 /epan/dissectors/packet-rx.c
parent98cc46f2a4ce695f8a38cbe56c8d87a1cf6873dd (diff)
Make RX a new style dissector: return 0 if there isn't at least 28 bytes of message or if it receives an unknown Type. Add a check of tvb length to README.developer's cut-n-paste dissector code.
svn path=/trunk/; revision=21300
Diffstat (limited to 'epan/dissectors/packet-rx.c')
-rw-r--r--epan/dissectors/packet-rx.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/epan/dissectors/packet-rx.c b/epan/dissectors/packet-rx.c
index 191c05db75..5f4bd72528 100644
--- a/epan/dissectors/packet-rx.c
+++ b/epan/dissectors/packet-rx.c
@@ -452,7 +452,7 @@ dissect_rx_flags(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *parent_tree,
return offset;
}
-static void
+static int
dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
{
proto_tree *tree;
@@ -463,6 +463,15 @@ dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
guint32 seq, callnumber;
guint16 serviceid;
+ /* Ensure we have enough data */
+ if (tvb_length(tvb) < 28)
+ return 0;
+
+ /* Make sure it's a known type */
+ type = tvb_get_guint8(tvb, 20);
+ if (type == 0 || type == 10 || type == 11 || type == 12 || type > 13)
+ return 0;
+
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RX");
if (check_col(pinfo->cinfo, COL_INFO))
@@ -582,6 +591,7 @@ dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
break;
}
+ return(tvb_length(tvb));
}
void
@@ -784,7 +794,7 @@ proto_reg_handoff_rx(void)
/* Ports in the range UDP_PORT_RX_LOW to UDP_PORT_RX_HIGH
are all used for various AFS services. */
- rx_handle = create_dissector_handle(dissect_rx, proto_rx);
+ rx_handle = new_create_dissector_handle(dissect_rx, proto_rx);
for (port = UDP_PORT_RX_LOW; port <= UDP_PORT_RX_HIGH; port++)
dissector_add("udp.port", port, rx_handle);
dissector_add("udp.port", UDP_PORT_RX_AFS_BACKUPS, rx_handle);