aboutsummaryrefslogtreecommitdiffstats
path: root/packet-tns.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-01-11 09:57:16 +0000
committerGuy Harris <guy@alum.mit.edu>2003-01-11 09:57:16 +0000
commit4a12e2d45d97b5065493719be42e0325a785894d (patch)
tree9f0df931cc8f18b8d02957d2311ee0365287be8a /packet-tns.c
parent01d8f313473acd29a4e734cb14d3dace4d5ab66e (diff)
Do some simple sanity checking of TNS data before dissecting it.
svn path=/trunk/; revision=6912
Diffstat (limited to 'packet-tns.c')
-rw-r--r--packet-tns.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/packet-tns.c b/packet-tns.c
index 85f63600bd..0b01bd6d71 100644
--- a/packet-tns.c
+++ b/packet-tns.c
@@ -1,7 +1,7 @@
/* packet-tns.c
* Routines for Oracle TNS packet dissection
*
- * $Id: packet-tns.c,v 1.36 2002/08/28 21:00:36 jmayer Exp $
+ * $Id: packet-tns.c,v 1.37 2003/01/11 09:57:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -849,11 +849,28 @@ get_tns_pdu_len(tvbuff_t *tvb, int offset)
return tvb_get_ntohs(tvb, offset);
}
-static void
+static int
dissect_tns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
+ guint8 type;
+
+ /*
+ * First, do a sanity check to make sure what we have
+ * starts with a TNS PDU.
+ */
+ if (tvb_bytes_exist(tvb, 4, 1)) {
+ /*
+ * Well, we have the packet type; let's make sure
+ * it's a known type.
+ */
+ type = tvb_get_guint8(tvb, 4);
+ if (type < TNS_TYPE_CONNECT || type > TNS_TYPE_MAX)
+ return 0; /* it's not a known type */
+ }
+
tcp_dissect_pdus(tvb, pinfo, tree, tns_desegment, 2,
get_tns_pdu_len, dissect_tns_pdu);
+ return tvb_length(tvb);
}
static void
@@ -1311,7 +1328,7 @@ proto_reg_handoff_tns(void)
{
dissector_handle_t tns_handle;
- tns_handle = create_dissector_handle(dissect_tns, proto_tns);
+ tns_handle = new_create_dissector_handle(dissect_tns, proto_tns);
dissector_add("tcp.port", TCP_PORT_TNS, tns_handle);
data_handle = find_dissector("data");
}