diff options
author | Simon McVittie <smcv@collabora.com> | 2022-09-12 13:33:52 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-10-07 14:15:52 +0100 |
commit | ba1cf69f38be890320a37b5929392a5795c97c07 (patch) | |
tree | 5c616d7afee6dd933a6c30b587b3c2e81c99cfdf /dbus | |
parent | f6c6c6a6a297d75ef9ecb6fc5bf2ad526057ce5d (diff) | |
download | dbus-ba1cf69f38be890320a37b5929392a5795c97c07.tar.gz |
dbus-marshal-basic: Assert that we are in-bounds after skipping items
We recommend disabling assertions in production builds of dbus, so it
is "cheap" to add them even in relatively fast-path locations.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-marshal-basic.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index 3b22aa70..6ebe5bd3 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -1193,6 +1193,10 @@ _dbus_marshal_skip_basic (const DBusString *str, _dbus_assert_not_reached ("not a basic type"); break; } + + /* We had better still be in-bounds at this point (pointing either into + * the content of the string, or 1 past the logical length of the string) */ + _dbus_assert (*pos <= _dbus_string_get_length (str)); } /** @@ -1230,6 +1234,10 @@ _dbus_marshal_skip_array (const DBusString *str, /* Skip the actual array data */ *pos = i + array_len; + + /* We had better still be in-bounds at this point (pointing either into + * the content of the string, or 1 past the logical length of the string) */ + _dbus_assert (*pos <= _dbus_string_get_length (str)); } /** |