wiretap: fix writing of 1 bytes long options in pcapng files
authorPascal Quantin <pascal.quantin@gmail.com>
Wed, 4 May 2016 17:06:30 +0000 (19:06 +0200)
committerMichael Mann <mmann78@netscape.net>
Wed, 4 May 2016 21:04:27 +0000 (21:04 +0000)
the option length should be 1 byte, not 4 bytes.

Change-Id: I1b356c7ce101f9bbdc9793fc280b6564e12f303f
Reviewed-on: https://code.wireshark.org/review/15265
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
wiretap/wtap_opttypes.c

index 4ecc9bd7a0480cdb18d0fb4cddbd52d41375cc54..7e3b4837c51cdf1139a0e7bcac51fee541a6f9f5 100644 (file)
@@ -254,8 +254,14 @@ static guint32 wtap_optionblock_get_option_write_size(wtap_optionblock_t block)
             length = value->info->write_size(&value->option);
             options_total_length += length;
             /* Add bytes for option header if option should be written */
-            if (length > 0)
+            if (length > 0) {
+                /* Add optional padding to 32 bits */
+                if ((options_total_length & 0x03) != 0)
+                {
+                    options_total_length += 4 - (options_total_length & 0x03);
+                }
                 options_total_length += 4;
+            }
         }
     }
 
@@ -529,8 +535,7 @@ guint32 wtap_opttype_write_uint8_not0(wtap_option_type* data)
     if (data->uint8val == 0)
         return 0;
 
-    /* padding to 32 bits */
-    return 4;
+    return 1;
 }
 
 gboolean wtap_opttype_write_data_uint8(struct wtap_dumper* wdh, wtap_option_type* data, int *err)