From 776280fa0d2ef480ec10cc6744e6ab31985c3c54 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 6 Oct 2004 09:59:50 +0000 Subject: Properly reject packets that don't look like NDMP packets. svn path=/trunk/; revision=12216 --- epan/dissectors/packet-ndmp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'epan/dissectors/packet-ndmp.c') diff --git a/epan/dissectors/packet-ndmp.c b/epan/dissectors/packet-ndmp.c index eb16e496ba..fa8fbe3c69 100644 --- a/epan/dissectors/packet-ndmp.c +++ b/epan/dissectors/packet-ndmp.c @@ -2754,7 +2754,7 @@ dissect_ndmp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, return TRUE; } -static void +static int dissect_ndmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { int offset = 0; @@ -2768,23 +2768,28 @@ dissect_ndmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) len = dissect_rpc_fragment(tvb, offset, pinfo, tree, dissect_ndmp_message, FALSE, proto_ndmp, ett_ndmp, ndmp_defragment, first_pdu); - first_pdu = FALSE; if (len < 0) { /* * We need more data from the TCP stream for * this fragment. */ - return; + return tvb_length(tvb); } if (len == 0) { /* * It's not NDMP. Stop processing. + * Return a "this isn't NDMP" indication + * if this is the first PDU. */ + if (first_pdu) + return 0; break; } + first_pdu = FALSE; offset += len; } + return tvb_length(tvb); } void @@ -3489,6 +3494,6 @@ proto_reg_handoff_ndmp(void) { dissector_handle_t ndmp_handle; - ndmp_handle = create_dissector_handle(dissect_ndmp, proto_ndmp); + ndmp_handle = new_create_dissector_handle(dissect_ndmp, proto_ndmp); dissector_add("tcp.port",TCP_PORT_NDMP, ndmp_handle); } -- cgit v1.2.3