From 49a5dd93908043c91e155f43a6da1329fbe49279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 13 Dec 2017 11:05:35 +0200 Subject: [PATCH] Fix BIT size calculation The size of a BIT field was not calculated correctly. --- server/modules/routing/avrorouter/avro_rbr.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/modules/routing/avrorouter/avro_rbr.c b/server/modules/routing/avrorouter/avro_rbr.c index f394bad66..61aef24a0 100644 --- a/server/modules/routing/avrorouter/avro_rbr.c +++ b/server/modules/routing/avrorouter/avro_rbr.c @@ -581,11 +581,9 @@ uint8_t* process_row_event_data(TABLE_MAP *map, TABLE_CREATE *create, avro_value else if (column_is_bit(map->column_types[i])) { uint64_t value = 0; - int width = metadata[metadata_offset] + metadata[metadata_offset + 1] * 8; - int bits_in_nullmap = MXS_MIN(width, extra_bits); - extra_bits -= bits_in_nullmap; - width -= bits_in_nullmap; - size_t bytes = width / 8; + uint8_t len = metadata[metadata_offset + 1]; + uint8_t bit_len = metadata[metadata_offset] > 0 ? 1 : 0; + size_t bytes = len + bit_len; // TODO: extract the bytes if (!warn_bit)