file-pcapng: fix dissection of options in blocks
authorPascal Quantin <pascal.quantin@gmail.com>
Wed, 19 Aug 2015 19:48:46 +0000 (21:48 +0200)
committerPascal Quantin <pascal.quantin@gmail.com>
Thu, 20 Aug 2015 10:04:13 +0000 (10:04 +0000)
- fix the loop logic
- flags in EPB include link-layer-dependent errors

Change-Id: Iae0b4869b556abbf3c14f3b865d0f23cee182c84
Reviewed-on: https://code.wireshark.org/review/10132
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
epan/dissectors/file-pcapng.c

index c53a2eea031d891709d8801e0038ef66031714d5..f1d574b642487ba0e70917cdab4e304ea42d457f 100644 (file)
@@ -488,7 +488,6 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo,
     proto_item  *option_item;
     proto_item  *p_item;
     gint         offset = 0;
-    gint         offset_option_start;
     guint16      option_code;
     gint         option_length;
     gint         hfj_pcapng_option_code;
@@ -508,8 +507,7 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo,
     options_item = proto_tree_add_item(tree, hf_pcapng_options, tvb, offset, -1, ENC_NA);
     options_tree = proto_item_add_subtree(options_item, ett_pcapng_options);
 
-    offset_option_start = offset;
-    while (tvb_reported_length(tvb) - (offset_option_start - offset) > 0) {
+    while (tvb_captured_length_remaining(tvb, offset)) {
         str = NULL;
         option_code   = tvb_get_guint16(tvb, offset, encoding);
         option_length = tvb_get_guint16(tvb, offset + 2, encoding);
@@ -956,8 +954,19 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo,
                     break;
                 }
 
-                proto_tree_add_bitmask(option_tree, tvb, offset, hf_pcapng_option_data_packet_flags, ett_pcapng_option, hfx_pcapng_option_data_packet_flags, encoding);
-                offset += 4;
+                if (encoding == ENC_LITTLE_ENDIAN) {
+                    proto_tree_add_bitmask(option_tree, tvb, offset, hf_pcapng_option_data_packet_flags, ett_pcapng_option, hfx_pcapng_option_data_packet_flags, encoding);
+                    offset += 2;
+
+                    proto_tree_add_bitmask(option_tree, tvb, offset, hf_pcapng_option_data_packet_flags_link_layer_errors, ett_pcapng_option, hfx_pcapng_option_data_packet_flags_link_layer_errors, encoding);
+                    offset += 2;
+                } else {
+                    proto_tree_add_bitmask(option_tree, tvb, offset, hf_pcapng_option_data_packet_flags_link_layer_errors, ett_pcapng_option, hfx_pcapng_option_data_packet_flags_link_layer_errors, encoding);
+                    offset += 2;
+
+                    proto_tree_add_bitmask(option_tree, tvb, offset, hf_pcapng_option_data_packet_flags, ett_pcapng_option, hfx_pcapng_option_data_packet_flags, encoding);
+                    offset += 2;
+                }
 
                 break;
             case 0x0003: