diff options
author | Adrian Szyndela <adrian.s@samsung.com> | 2018-05-23 12:49:48 +0200 |
---|---|---|
committer | Adrian Szyndela <adrian.s@samsung.com> | 2018-05-23 12:55:14 +0200 |
commit | 23ff0ed3a5205afd2067514b25aed3aa5c51f4cc (patch) | |
tree | 57329447a4576354463d56c472f2e4833de1518e | |
parent | 2a318a5abf412616d4e92f3774c7f474e5c53349 (diff) | |
download | dbus-23ff0ed3a5205afd2067514b25aed3aa5c51f4cc.tar.gz dbus-23ff0ed3a5205afd2067514b25aed3aa5c51f4cc.tar.bz2 dbus-23ff0ed3a5205afd2067514b25aed3aa5c51f4cc.zip |
GVariant: fix alignment of elements in arraysubmit/tizen_4.0/20180524.054843accepted/tizen/4.0/unified/20180524.131144
This patch fixes two related bugs:
1. off-by-one in checking size and alignment of the next element
in_dbus_reader_get_signature_fixed_size()
2. alignment requirements were not considered at all while iterating
over array of variable size elements in array_reader_next().
Change-Id: Ic24be50e978532da4695a2a35731302011e20871
-rw-r--r-- | dbus/dbus-marshal-gvariant.c | 2 | ||||
-rw-r--r-- | dbus/dbus-marshal-recursive.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/dbus/dbus-marshal-gvariant.c b/dbus/dbus-marshal-gvariant.c index 2adee4d0..d270dd3e 100644 --- a/dbus/dbus-marshal-gvariant.c +++ b/dbus/dbus-marshal-gvariant.c @@ -945,7 +945,7 @@ _dbus_reader_get_signature_fixed_size (const DBusString *signature, int *pos, in res = update_size (res, res_recursive, ¤t_alignment, alignment_recursive); /* and update position */ - *pos = recursive_pos - 1; + *pos = recursive_pos; } break; case DBUS_TYPE_INVALID: diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c index af027edc..4e899274 100644 --- a/dbus/dbus-marshal-recursive.c +++ b/dbus/dbus-marshal-recursive.c @@ -684,8 +684,10 @@ array_reader_next (DBusTypeReader *reader, int size = _dbus_reader_get_type_fixed_size (reader, &alignment); if (0 == size) { - /* variable size - use offsets*/ - reader->value_pos = _dbus_reader_get_offset_of_end_of_variable (reader); + /* variable size - use offsets - BUT consider also alignment, + because elements in the array might have alignment requirements. + */ + reader->value_pos = _DBUS_ALIGN_VALUE(_dbus_reader_get_offset_of_end_of_variable (reader), alignment); reader->variable_index++; reader->finished = (reader->variable_index >= reader->n_offsets); } |