aboutsummaryrefslogtreecommitdiffstats
path: root/packet-tpkt.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-05-13 21:18:26 +0000
committerGuy Harris <guy@alum.mit.edu>2002-05-13 21:18:26 +0000
commitc845015f0645b6da7e5d7dc8f02002f3713651d0 (patch)
tree085dcc250e18aa4a38218fde65029f263ad216bd /packet-tpkt.c
parenta92af3868dc04904daf6148b1b8368bdbddb9572 (diff)
Have "is_tpkt()" take a minimum-payload-length argument and check
whether the length value in the TPKT header is large enough to include that much payload - if not, report the packet as not being a TPKT packet. Have the heuristic Q.931 dissector supply the appropriate value. svn path=/trunk/; revision=5457
Diffstat (limited to 'packet-tpkt.c')
-rw-r--r--packet-tpkt.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/packet-tpkt.c b/packet-tpkt.c
index faa956e0d2..cdf944f76a 100644
--- a/packet-tpkt.c
+++ b/packet-tpkt.c
@@ -7,7 +7,7 @@
* Routine to dissect RFC 1006 TPKT packet containing OSI TP PDU
* Copyright 2001, Martin Thomas <Martin_A_Thomas@yahoo.com>
*
- * $Id: packet-tpkt.c,v 1.18 2002/03/25 20:17:09 guy Exp $
+ * $Id: packet-tpkt.c,v 1.19 2002/05/13 21:18:25 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -71,10 +71,16 @@ static dissector_handle_t osi_tp_handle;
* Check whether this could be a TPKT-encapsulated PDU.
* Returns -1 if it's not, and the PDU length from the TPKT header
* if it is.
+ *
+ * "min_len" is the minimum length of the PDU; the length field in the
+ * TPKT header must be at least "4+min_len" in order for this to be a
+ * valid TPKT PDU for the protocol in question.
*/
int
-is_tpkt(tvbuff_t *tvb)
+is_tpkt(tvbuff_t *tvb, int min_len)
{
+ guint16 pkt_len;
+
/*
* If TPKT is disabled, don't dissect it, just return -1, meaning
* "this isn't TPKT".
@@ -92,12 +98,20 @@ is_tpkt(tvbuff_t *tvb)
* always be the case....
*/
if (!(tvb_get_guint8(tvb, 0) == 3 && tvb_get_guint8(tvb, 1) == 0))
- return -1; /* They're not */
+ return -1; /* they're not */
+
+ /*
+ * Get the length from the TPKT header. Make sure it's large
+ * enough.
+ */
+ pkt_len = tvb_get_ntohs(tvb, 2);
+ if (pkt_len < 4 + min_len)
+ return -1; /* it's not */
/*
- * Return the length from the TPKT header.
+ * Return the length from the header.
*/
- return tvb_get_ntohs(tvb, 2);
+ return pkt_len;
}
/*