diff options
author | Simon McVittie <smcv@collabora.com> | 2022-09-12 13:17:55 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-10-07 14:15:45 +0100 |
commit | 1b9e00532208f96370b5783592932f5cd7128b39 (patch) | |
tree | 6f26b1a50f5f4064d53ec7cf28f4953e402edfbd /dbus | |
parent | 606795f90868c2cb3fd83f506bf7dae090d56ff5 (diff) | |
download | dbus-1b9e00532208f96370b5783592932f5cd7128b39.tar.gz |
dbus-marshal-validate: Add more comments indicating what is going on
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-marshal-validate.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/dbus/dbus-marshal-validate.c b/dbus/dbus-marshal-validate.c index 28e622f7..c2f7030e 100644 --- a/dbus/dbus-marshal-validate.c +++ b/dbus/dbus-marshal-validate.c @@ -368,10 +368,12 @@ validate_body_helper (DBusTypeReader *reader, switch (current_type) { + /* Special case of fixed-length types: every byte is valid */ case DBUS_TYPE_BYTE: ++p; break; + /* Multi-byte fixed-length types require padding to their alignment */ case DBUS_TYPE_BOOLEAN: case DBUS_TYPE_INT16: case DBUS_TYPE_UINT16: @@ -408,6 +410,7 @@ validate_body_helper (DBusTypeReader *reader, p += alignment; break; + /* Types that start with a 4-byte length */ case DBUS_TYPE_ARRAY: case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: @@ -430,6 +433,10 @@ validate_body_helper (DBusTypeReader *reader, /* p may now be == end */ _dbus_assert (p <= end); + /* Arrays have padding between the length and the first + * array item, if it's necessary for the array's element type. + * This padding is not counted as part of the length + * claimed_len. */ if (current_type == DBUS_TYPE_ARRAY) { int array_elem_type = _dbus_type_reader_get_element_type (reader); |