Check for a zero offset in the "get status" reply *before* adding the
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 24 Jan 2014 07:55:03 +0000 (07:55 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 24 Jan 2014 07:55:03 +0000 (07:55 +0000)
offset in the tvbuff of the beginning of the packet to it.  Otherwise,
it will never be zero, and the tests will always think the field pointed
to by the offset is present.

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

epan/dissectors/packet-atalk.c
epan/dissectors/packet-dsi.c

index e6885745c4e198922076fb966501568644859dab..26f63331fd1025af41ea13d02a7e80b591886423 100644 (file)
@@ -1055,8 +1055,9 @@ dissect_asp_reply_get_status(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
   if (machine_ofs)
     proto_tree_add_item(tree, hf_asp_server_type, tvb, machine_ofs, 1, ENC_ASCII|ENC_NA);
 
-  ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_VERSOFF);
+  ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_VERSOFF);
   if (ofs) {
+    ofs += offset;
     nbe = tvb_get_guint8(tvb, ofs);
     ti = proto_tree_add_text(tree, tvb, ofs, 1, "Version list: %u", nbe);
     ofs++;
@@ -1068,8 +1069,9 @@ dissect_asp_reply_get_status(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
     }
   }
 
-  ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_UAMSOFF);
+  ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_UAMSOFF);
   if (ofs) {
+    ofs += offset;
     nbe = tvb_get_guint8(tvb, ofs);
     ti = proto_tree_add_text(tree, tvb, ofs, 1, "UAMS list: %u", nbe);
     ofs++;
@@ -1081,9 +1083,11 @@ dissect_asp_reply_get_status(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *
     }
   }
 
-  ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_ICONOFF);
-  if (ofs)
+  ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_ICONOFF);
+  if (ofs) {
+    ofs += offset;
     proto_tree_add_item(tree, hf_asp_server_icon, tvb, ofs, 256, ENC_NA);
+  }
 
   if (sign_ofs) {
     proto_tree_add_item(tree, hf_asp_server_signature, tvb, sign_ofs, 16, ENC_NA);
index 1c8c6b386cb23081df2840d3ebd87b1918cb1880..124cb75ff6036aa89d5eedba8df286d36e7a6209 100644 (file)
@@ -344,7 +344,8 @@ dissect_dsi_reply_get_status(tvbuff_t *tvb, proto_tree *tree, gint offset)
 
                sign_ofs = tvb_get_ntohs(tvb, ofs);
                proto_tree_add_text(tree, tvb, ofs, 2, "Signature offset: %d", sign_ofs);
-               sign_ofs += offset;
+               if (sign_ofs)
+                       sign_ofs += offset;
 
                if ((flag & AFPSRVRINFO_TCPIP)) {
                        ofs += 2;
@@ -367,12 +368,15 @@ dissect_dsi_reply_get_status(tvbuff_t *tvb, proto_tree *tree, gint offset)
                }
        }
 
-       ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_MACHOFF);
-       if (ofs)
+       ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_MACHOFF);
+       if (ofs) {
+               ofs += offset;
                proto_tree_add_item(tree, hf_dsi_server_type, tvb, ofs, 1, ENC_ASCII|ENC_NA);
+       }
 
-       ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_VERSOFF);
+       ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_VERSOFF);
        if (ofs) {
+               ofs += offset;
                nbe = tvb_get_guint8(tvb, ofs);
                ti = proto_tree_add_text(tree, tvb, ofs, 1, "Version list: %d", nbe);
                ofs++;
@@ -384,8 +388,9 @@ dissect_dsi_reply_get_status(tvbuff_t *tvb, proto_tree *tree, gint offset)
                }
        }
 
-       ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_UAMSOFF);
+       ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_UAMSOFF);
        if (ofs) {
+               ofs += offset;
                nbe = tvb_get_guint8(tvb, ofs);
                ti = proto_tree_add_text(tree, tvb, ofs, 1, "UAMS list: %d", nbe);
                ofs++;
@@ -397,9 +402,11 @@ dissect_dsi_reply_get_status(tvbuff_t *tvb, proto_tree *tree, gint offset)
                }
        }
 
-       ofs = offset +tvb_get_ntohs(tvb, offset +AFPSTATUS_ICONOFF);
-       if (ofs)
+       ofs = tvb_get_ntohs(tvb, offset +AFPSTATUS_ICONOFF);
+       if (ofs) {
+               ofs += offset;
                proto_tree_add_item(tree, hf_dsi_server_icon, tvb, ofs, 256, ENC_NA);
+       }
 
        if (sign_ofs) {
                proto_tree_add_item(tree, hf_dsi_server_signature, tvb, sign_ofs, 16, ENC_NA);