From: Simon McVittie Date: Mon, 15 Feb 2016 13:52:52 +0000 (+0000) Subject: Statically assert that the DBusMessageIter struct has no padding X-Git-Tag: dbus-1.10.8~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64d6dbd190f5d58768fbf290747b06e464d44b00;p=thirdparty%2Fdbus.git Statically assert that the DBusMessageIter struct has no padding Signed-off-by: Simon McVittie Reviewed-by: Thiago Macieira Bug: https://bugs.freedesktop.org/show_bug.cgi?id=94136 --- diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index abdc11f31..e22fe51b3 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -2058,6 +2058,11 @@ _dbus_message_iter_init_common (DBusMessage *message, sizeof (DBusMessageIter)); _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (DBusMessageIter_1_10_0) == _DBUS_ALIGNOF (DBusMessageIter)); + /* If this static assertion fails, it means the DBusMessageIter struct + * is not "packed", which might result in "iter = other_iter" not copying + * every byte. */ + _DBUS_STATIC_ASSERT (sizeof (DBusMessageIter) == + 4 * sizeof (void *) + sizeof (dbus_uint32_t) + 9 * sizeof (int)); /* Since the iterator will read or write who-knows-what from the * message, we need to get in the right byte order