affdba
diff --git a/epan/dissectors/packet-zbee-security.c b/epan/dissectors/packet-zbee-security.c
affdba
index 14fdb0a..34bc1a8 100644
affdba
--- a/epan/dissectors/packet-zbee-security.c
affdba
+++ b/epan/dissectors/packet-zbee-security.c
affdba
@@ -590,11 +590,9 @@ dissect_zbee_secure(tvbuff_t *tvb, packet_info *pinfo, proto_tree* tree, guint o
affdba
     }
affdba
 
affdba
     /* Check for null payload. */
affdba
-    if ( !(payload_len = tvb_reported_length_remaining(tvb, offset+mic_len)) ) {
affdba
+    payload_len = tvb_captured_length_remaining(tvb, offset+mic_len);
affdba
+    if (payload_len == 0)
affdba
         return NULL;
affdba
-    } else if ( payload_len < 0 ) {
affdba
-        THROW(ReportedBoundsError);
affdba
-    }
affdba
 
affdba
     /**********************************************
affdba
      *  Perform Security Operations on the Frame  *
affdba
@@ -606,10 +604,31 @@ dissect_zbee_secure(tvbuff_t *tvb, packet_info *pinfo, proto_tree* tree, guint o
affdba
         (packet.level == ZBEE_SEC_MIC128)) {
affdba
 
affdba
         /* Payload is only integrity protected. Just return the sub-tvbuff. */
affdba
-        return tvb_new_subset(tvb, offset, payload_len, payload_len);
affdba
+        return tvb_new_subset_length(tvb, offset, payload_len);
affdba
     }
affdba
 
affdba
 #ifdef HAVE_LIBGCRYPT
affdba
+    /* Have we captured all the payload? */
affdba
+    if (tvb_length_remaining(tvb, offset+mic_len) < payload_len) {
affdba
+        /*
affdba
+         * No - don't try to decrypt it.
affdba
+         *
affdba
+         * XXX - it looks as if the decryption code is assuming we have the
affdba
+         * MIC, which won't be the case if the packet was cut short.  Is
affdba
+         * that in fact that case, or can we still make this work with a
affdba
+         * partially-captured packet?
affdba
+         */
affdba
+        /* Add expert info. */
affdba
+        expert_add_info_format(pinfo, sec_tree, PI_UNDECODED, PI_WARN,
affdba
+                "Encrypted payload, cut short when capturing - can't decrypt");
affdba
+        /* Create a buffer for the undecrypted payload. */
affdba
+        payload_tvb = tvb_new_subset_length(tvb, offset, payload_len);
affdba
+        /* Dump the payload to the data dissector. */
affdba
+        call_dissector(data_handle, payload_tvb, pinfo, tree);
affdba
+        /* Couldn't decrypt, so return NULL. */
affdba
+        return NULL;
affdba
+    }
affdba
+
affdba
     /* Allocate memory to decrypt the payload into. */
affdba
     dec_buffer = (guint8 *)g_malloc(payload_len);
affdba