From a6a8745bea720727f0aae0acb269dfe3d674305f Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Wed, 4 May 2016 19:06:30 +0200 Subject: wiretap: fix writing of 1 bytes long options in pcapng files 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 Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- wiretap/wtap_opttypes.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'wiretap/wtap_opttypes.c') diff --git a/wiretap/wtap_opttypes.c b/wiretap/wtap_opttypes.c index 4ecc9bd7a0..7e3b4837c5 100644 --- a/wiretap/wtap_opttypes.c +++ b/wiretap/wtap_opttypes.c @@ -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) -- cgit v1.2.1