diff options
author | Simon McVittie <smcv@collabora.com> | 2022-09-12 13:29:38 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-10-07 14:15:48 +0100 |
commit | f6c6c6a6a297d75ef9ecb6fc5bf2ad526057ce5d (patch) | |
tree | 6064ab558cb9c866fea1d0cceb8dd1f23e183f68 /dbus | |
parent | 1b9e00532208f96370b5783592932f5cd7128b39 (diff) | |
download | dbus-f6c6c6a6a297d75ef9ecb6fc5bf2ad526057ce5d.tar.gz |
dbus-marshal-basic: Clarify what is going on when we skip an item
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-marshal-basic.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index 3a79c527..3b22aa70 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -1149,6 +1149,7 @@ _dbus_marshal_skip_basic (const DBusString *str, break; case DBUS_TYPE_INT16: case DBUS_TYPE_UINT16: + /* Advance to the next suitably-aligned position >= *pos */ *pos = _DBUS_ALIGN_VALUE (*pos, 2); *pos += 2; break; @@ -1170,6 +1171,8 @@ _dbus_marshal_skip_basic (const DBusString *str, { int len; + /* Let len be the number of bytes of string data, and advance + * *pos to just after the length */ len = _dbus_marshal_read_uint32 (str, *pos, byte_order, pos); *pos += len + 1; /* length plus nul */ @@ -1211,14 +1214,21 @@ _dbus_marshal_skip_array (const DBusString *str, int i; int alignment; + /* Advance to the next 4-byte-aligned position >= *pos */ i = _DBUS_ALIGN_VALUE (*pos, 4); + /* Let array_len be the number of bytes of array data, and advance + * i to just after the length */ array_len = _dbus_marshal_read_uint32 (str, i, byte_order, &i); + /* If the element type is more strictly-aligned than the length, + * advance i to the next suitably-aligned position + * (in other words, skip the padding) */ alignment = _dbus_type_get_alignment (element_type); i = _DBUS_ALIGN_VALUE (i, alignment); + /* Skip the actual array data */ *pos = i + array_len; } |