Remove more tvb_length
authorEvan Huus <eapache@gmail.com>
Mon, 22 Jun 2015 21:40:23 +0000 (14:40 -0700)
committerEvan Huus <eapache@gmail.com>
Mon, 22 Jun 2015 21:40:50 +0000 (21:40 +0000)
Change-Id: I940704e927001b2a051a59fd0738e7a02328472b
Reviewed-on: https://code.wireshark.org/review/9031
Reviewed-by: Evan Huus <eapache@gmail.com>
epan/dissectors/file-png.c
epan/dissectors/packet-acr122.c
epan/dissectors/packet-bt-dht.c
epan/dissectors/packet-bt-utp.c
epan/dissectors/packet-bthid.c
epan/dissectors/packet-cisco-metadata.c

index 0ed86c73ff98f59c6d0f0a7277cedd35d2daa3ad..496e6c67c165a258ad18afc2de87ae2bc8296bbf 100644 (file)
@@ -324,7 +324,7 @@ dissect_png_text(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
 {
     gint offset=0, nul_offset;
 
-    nul_offset = tvb_find_guint8(tvb, offset, tvb_length_remaining(tvb, offset), 0);
+    nul_offset = tvb_find_guint8(tvb, offset, tvb_captured_length_remaining(tvb, offset), 0);
     /* nul_offset == 0 means empty keyword, this is not allowed by the png standard */
     if (nul_offset<=0) {
         /* XXX exception */
@@ -334,7 +334,7 @@ dissect_png_text(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
     proto_tree_add_item(tree, &hfi_png_text_keyword, tvb, offset, nul_offset, ENC_ISO_8859_1|ENC_NA);
     offset = nul_offset+1; /* length of the key word + 0 character */
 
-    proto_tree_add_item(tree, &hfi_png_text_string, tvb, offset, tvb_length_remaining(tvb, offset), ENC_ISO_8859_1|ENC_NA);
+    proto_tree_add_item(tree, &hfi_png_text_string, tvb, offset, tvb_captured_length_remaining(tvb, offset), ENC_ISO_8859_1|ENC_NA);
 
 }
 
index b134c2ccc818939f4cc6c4d61c037106ec16b012..10a065044ec002916c1906db85877c5a416babe5 100644 (file)
@@ -501,37 +501,37 @@ dissect_acr122(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
             }
         }
 
-        sub_item = proto_tree_add_uint(main_tree, hf_response, tvb, offset, tvb_length_remaining(tvb, offset), command);
+        sub_item = proto_tree_add_uint(main_tree, hf_response, tvb, offset, tvb_captured_length_remaining(tvb, offset), command);
         PROTO_ITEM_SET_GENERATED(sub_item);
 
         col_add_fstr(pinfo->cinfo, COL_INFO, "Response: %s", val_to_str_ext_const(command, &command_vals_ext, "Unknown"));
 
         if (command != CMD_UNKNOWN) {
-            sub_item = proto_tree_add_uint(main_tree, hf_response_for, tvb, offset, tvb_length_remaining(tvb, offset), command_frame_number);
+            sub_item = proto_tree_add_uint(main_tree, hf_response_for, tvb, offset, tvb_captured_length_remaining(tvb, offset), command_frame_number);
             PROTO_ITEM_SET_GENERATED(sub_item);
         }
 
         switch (command) {
         case CMD_GET_FIRMWARE_VERSION:
             proto_tree_add_item(main_tree, hf_firmware_version, tvb, offset, -1, ENC_NA | ENC_ASCII);
-            offset += tvb_length_remaining(tvb, offset);
+            offset += tvb_captured_length_remaining(tvb, offset);
             break;
 
         case CMD_DIRECT_TRANSMIT:
             use_status_word = TRUE;
 
-            if (tvb_length_remaining(tvb, offset) > 2) {
-                next_tvb = tvb_new_subset_length(tvb, offset, tvb_length_remaining(tvb, offset) - 2);
+            if (tvb_captured_length_remaining(tvb, offset) > 2) {
+                next_tvb = tvb_new_subset_length(tvb, offset, tvb_captured_length_remaining(tvb, offset) - 2);
                 call_dissector_with_data(pn532_handle, next_tvb, pinfo, tree, usb_conv_info);
-                offset += tvb_length_remaining(tvb, offset) - 2;
+                offset += tvb_captured_length_remaining(tvb, offset) - 2;
             }
             break;
 
 
         case CMD_READ_BINARY_BLOCKS:
             use_status_word = TRUE;
-            proto_tree_add_item(main_tree, hf_data, tvb, offset, tvb_length_remaining(tvb, offset) - 2, ENC_NA);
-            offset += tvb_length_remaining(tvb, offset) - 2;
+            proto_tree_add_item(main_tree, hf_data, tvb, offset, tvb_captured_length_remaining(tvb, offset) - 2, ENC_NA);
+            offset += tvb_captured_length_remaining(tvb, offset) - 2;
             break;
 
         case CMD_READ_VALUE_BLOCK:
@@ -541,14 +541,14 @@ dissect_acr122(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
 
         case CMD_GET_DATA_UID:
             use_status_word = TRUE;
-            proto_tree_add_item(main_tree, hf_uid, tvb, offset, tvb_length_remaining(tvb, offset) - 2, ENC_NA);
-            offset += tvb_length_remaining(tvb, offset) - 2;
+            proto_tree_add_item(main_tree, hf_uid, tvb, offset, tvb_captured_length_remaining(tvb, offset) - 2, ENC_NA);
+            offset += tvb_captured_length_remaining(tvb, offset) - 2;
             break;
 
         case CMD_GET_DATA_ATS:
             use_status_word = TRUE;
-            proto_tree_add_item(main_tree, hf_ats, tvb, offset, tvb_length_remaining(tvb, offset) - 2, ENC_NA);
-            offset += tvb_length_remaining(tvb, offset) - 2;
+            proto_tree_add_item(main_tree, hf_ats, tvb, offset, tvb_captured_length_remaining(tvb, offset) - 2, ENC_NA);
+            offset += tvb_captured_length_remaining(tvb, offset) - 2;
             break;
 
         case CMD_BI_COLOR_AND_BUZZER_LED_CONTROL:
index 84184552ae097393e2ecc2fc972dec777a7ef2d2..6b6889f515d01a82f8760cd092dcc1fdbbe2e2d1 100644 (file)
@@ -477,7 +477,7 @@ gboolean dissect_bt_dht_heur (tvbuff_t *tvb, packet_info *pinfo,
   /* try dissecting */
   /* Assume dictionary (d) is followed by a one char long (1:) key string. */
 
-  if(tvb_length(tvb) < 4)
+  if(tvb_captured_length(tvb) < 4)
     return FALSE;
 
   if(tvb_memeql(tvb, 0, "d1:", 3) != 0)
index ea9b155013314e48d414029f7d7b3b042d8f0514..1b00ba3e82f6e3bc25692de58afaef90b4f71914 100644 (file)
@@ -161,7 +161,7 @@ get_utp_version(tvbuff_t *tvb) {
 
   /* Simple heuristics inspired by code from utp.cpp */
 
-  len = tvb_length(tvb);
+  len = tvb_captured_length(tvb);
 
   /* Version 1? */
   if (len < V1_FIXED_HDR_SIZE) {
@@ -357,7 +357,7 @@ dissect_bt_utp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
 
     offset = dissect_utp_extension(tvb, pinfo, sub_tree, offset, &extension_type);
 
-    len_tvb = tvb_length_remaining(tvb, offset);
+    len_tvb = tvb_captured_length_remaining(tvb, offset);
     if(len_tvb > 0)
       proto_tree_add_item(sub_tree, hf_bt_utp_data, tvb, offset, len_tvb, ENC_NA);
 
index d6667700dcc70b0cfa94d1478fc8111175b43687..a122b6a923e77318609c0536b1484b2dbdb05246 100644 (file)
@@ -230,8 +230,8 @@ dissect_bthid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U
                Global Items are declared in the report descriptor, and in
                Boot Protocol Mode. Otherwise the field does not exist."
             */
-            if (((parameter >> 3) && tvb_length_remaining(tvb, offset) >= 3) ||
-                    (!(parameter >> 3) && tvb_length_remaining(tvb, offset) >= 1)) {
+            if (((parameter >> 3) && tvb_reported_length_remaining(tvb, offset) >= 3) ||
+                    (!(parameter >> 3) && tvb_reported_length_remaining(tvb, offset) >= 1)) {
                 proto_tree_add_item(bthid_tree, hf_bthid_report_id, tvb, offset, 1, ENC_BIG_ENDIAN);
                 offset += 1;
             }
@@ -251,7 +251,7 @@ dissect_bthid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U
 
             /* playload */
             proto_tree_add_item(bthid_tree, hf_bthid_data, tvb, offset, -1, ENC_NA);
-            offset += tvb_length_remaining(tvb, offset);
+            offset += tvb_captured_length_remaining(tvb, offset);
             break;
         case 0x06: /* GET_PROTOCOL */
             proto_tree_add_item(bthid_tree, hf_bthid_parameter_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
index e8b26eae7bd45e9fc28081f18a92d63129ba2fe3..115692c52fb3cd21edfc5d8327590947348a35da 100644 (file)
@@ -82,7 +82,7 @@ dissect_cmd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         gboolean is_802_2 = TRUE;
 
         /* Don't throw an exception for this check (even a BoundsError) */
-        if (tvb_length_remaining(tvb, 4) >= 2) {
+        if (tvb_captured_length_remaining(tvb, 4) >= 2) {
             if (tvb_get_ntohs(tvb, 4) == 0xffff)
                 is_802_2 = FALSE;
         }