diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2016-05-04 19:06:30 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-05-04 21:04:27 +0000 |
commit | a6a8745bea720727f0aae0acb269dfe3d674305f (patch) | |
tree | 93607356864ce100f04d281eab5c7ea29e3b2c9b /wiretap/wtap_opttypes.c | |
parent | 5b1d42c46a7b3dd58d21e6ed390506b1d35a8807 (diff) | |
download | wireshark-a6a8745bea720727f0aae0acb269dfe3d674305f.tar.gz |
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 <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>
Diffstat (limited to 'wiretap/wtap_opttypes.c')
-rw-r--r-- | wiretap/wtap_opttypes.c | 11 |
1 files changed, 8 insertions, 3 deletions
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) |