From: Simon McVittie Date: Mon, 15 Feb 2016 14:58:59 +0000 (+0000) Subject: DBusMessage: assert the properties we need DBusMessageIter to have X-Git-Tag: dbus-1.10.8~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=338cfa15992b73d2cd43a50c84bf5ebc4eeda04f;p=thirdparty%2Fdbus.git DBusMessage: assert the properties we need DBusMessageIter to have We already asserted that DBusMessageIter must be at least as large as DBusMessageRealIter (so that casting DBusMessageIter * to DBusMessageRealIter * does not result in overflowing the stack variable). Also assert that it must have alignment requirements at least as strict as those of DBusMessageRealIter * (so that casting does not increase the required alignment). 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 699e022b6..50e87cae8 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -2025,7 +2025,10 @@ _dbus_message_iter_init_common (DBusMessage *message, DBusMessageRealIter *real, int iter_type) { + /* If these static assertions fail on your platform, report it as a bug. */ _DBUS_STATIC_ASSERT (sizeof (DBusMessageRealIter) <= sizeof (DBusMessageIter)); + _DBUS_STATIC_ASSERT (_DBUS_ALIGNOF (DBusMessageRealIter) <= + _DBUS_ALIGNOF (DBusMessageIter)); /* Since the iterator will read or write who-knows-what from the * message, we need to get in the right byte order