Properly reject packets that don't look like NDMP packets.
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 6 Oct 2004 09:59:50 +0000 (09:59 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 6 Oct 2004 09:59:50 +0000 (09:59 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@12216 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-ndmp.c

index eb16e496bac149df6c55c40c41097c04185e15ad..fa8fbe3c69b3d379279665e2393c2cda818ebb73 100644 (file)
@@ -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);
 }