- New-style dissectors need to always return "bytes dissected" (not just when tree...
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 20 Apr 2011 17:25:07 +0000 (17:25 +0000)
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 20 Apr 2011 17:25:07 +0000 (17:25 +0000)
- The dissector probably shouldn't return a value for "bytes dissected" which is larger
   than the tvb length (altho there's actually no harm given the current implementation).
- Don't try to do an 'add_item' with an offset past the end of the tvb (altho again there's
   no actual harm in this case).

ToDo: Handle "original format" uTP headers.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36737 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-bt-utp.c

index b8a42db1abbab1a16db84ebba3b89ad1f37abb4a..5984fc3426ebea31aa54fb4ecbeb0e65db9c4e05 100644 (file)
@@ -131,16 +131,14 @@ dissect_utp_header(tvbuff_t *tvb, proto_tree *tree)
   offset += 2;
 
   /* display the extension tree */
-  while(offset <= (int)tvb_length(tvb))
+
+  /* XXX: This code loops thru the packet bytes until reaching the end of the PDU
+   *      ignoring the "end-of-list" [EXT_NO_EXTENSION] extension type.
+   *      Should we just quit when EXT_NO_EXTENSION is encountered ?
+   */
+  while(offset < (int)tvb_length(tvb))
   {
     switch(extension_type){
-      case EXT_NO_EXTENSION: /* 0 */
-      {
-        ti = proto_tree_add_item(tree, hf_bt_utp_extension, tvb, offset, 1, FALSE);
-        proto_item_append_text(ti, " No Extension (End)");
-        offset += 1;
-        break;
-      }
       case EXT_SELECTION_ACKS: /* 1 */
       {
         ti = proto_tree_add_item(tree, hf_bt_utp_extension, tvb, offset, -1, FALSE);
@@ -160,7 +158,7 @@ dissect_utp_header(tvbuff_t *tvb, proto_tree *tree)
         proto_item_set_len(ti, 1 + 1 + extension_length);
         break;
       }
-      case EXT_EXTENSION_BITS: /* 1 */
+      case EXT_EXTENSION_BITS: /* 2 */
       {
         ti = proto_tree_add_item(tree, hf_bt_utp_extension, tvb, offset, -1, FALSE);
         ext_tree = proto_item_add_subtree(ti, ett_bt_utp_extension);
@@ -205,9 +203,9 @@ dissect_utp_header(tvbuff_t *tvb, proto_tree *tree)
 static int
 dissect_bt_utp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
-  proto_item *ti;
-  proto_tree *sub_tree;
-  int decoded_length = 0;
+  proto_tree *sub_tree = NULL;
+  int decoded_length;
+
   /* set the protocol column */
   col_set_str(pinfo->cinfo, COL_PROTOCOL, "BT-uTP");
   /* set the info column */
@@ -215,10 +213,13 @@ dissect_bt_utp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
   if(tree)
   {
+    proto_item *ti;
     ti = proto_tree_add_item(tree, proto_bt_utp, tvb, 0, -1, FALSE);
     sub_tree = proto_item_add_subtree(ti, ett_bt_utp);
-    decoded_length = dissect_utp_header(tvb, sub_tree);
   }
+
+  decoded_length = dissect_utp_header(tvb, sub_tree);
+
   return decoded_length;
 }