summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Szyndela <adrian.s@samsung.com>2016-10-14 15:24:43 +0200
committerAdrian Szyndela <adrian.s@samsung.com>2016-10-14 15:27:03 +0200
commit98ca091094df5b6f9084bc240d2ca55dfbfc2226 (patch)
tree6716701b0c85a78f8ac26cdd4f8e62ed34ef16da
parent92a5c831e2542a69bfd96b2664559e4ce72bca61 (diff)
downloaddbus-98ca091094df5b6f9084bc240d2ca55dfbfc2226.tar.gz
dbus-98ca091094df5b6f9084bc240d2ca55dfbfc2226.tar.bz2
dbus-98ca091094df5b6f9084bc240d2ca55dfbfc2226.zip
There is a requirement for fixed-size tuples: size of such tuple must be a multiply of its required alignment. That part was overlooked in the implementation. This commit adds padding accounting for both reading and writing. Change-Id: I0825be6436b93b836dc333f5a395fdf1021f2a06
-rw-r--r--dbus/dbus-marshal-gvariant.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/dbus/dbus-marshal-gvariant.c b/dbus/dbus-marshal-gvariant.c
index ebd07fea..1348965e 100644
--- a/dbus/dbus-marshal-gvariant.c
+++ b/dbus/dbus-marshal-gvariant.c
@@ -904,6 +904,10 @@ _dbus_reader_get_signature_fixed_size (const DBusString *signature, int *pos, in
case DBUS_STRUCT_END_CHAR:
case DBUS_DICT_ENTRY_END_CHAR:
depth--;
+ /* For fixed-size structs we need to account padding.
+ */
+ if (!variable)
+ res = _DBUS_ALIGN_VALUE (res, current_alignment);
break;
case DBUS_STRUCT_BEGIN_CHAR:
case DBUS_DICT_ENTRY_BEGIN_CHAR:
@@ -1366,6 +1370,17 @@ _dbus_writer_unrecurse_gvariant_write (DBusTypeWriter *writer,
writer->value_pos);
writer->value_pos += sub_len;
+ /* Structs may have padding if they are fixed-size structs.
+ * This is because of requirement that struct size must be a multiply
+ * of required alignment.
+ */
+ if (sub->is_fixed)
+ {
+ diff = _DBUS_ALIGN_VALUE (sub_len, sub->alignment) - sub_len;
+ result = result && _dbus_string_insert_bytes (writer->value_str, writer->value_pos, diff, 0);
+ writer->value_pos += diff;
+ }
+
_dbus_string_free (sub->value_str);
dbus_free (sub->value_str);