From 8614a746ecc3a743ae3d8a7c49e043c45681e7e0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 3 Mar 2011 16:29:17 +0000 Subject: [PATCH 3/4] dbus_message_iter_append_basic: validate booleans too Sending, for instance, ((dbus_bool_t) 666) is a programming error and should be diagnosed as such. --- dbus/dbus-message.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index c6b52f5..a8378e3 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -2519,6 +2519,7 @@ dbus_message_iter_append_basic (DBusMessageIter *iter, switch (type) { const char * const *string_p; + const dbus_bool_t *bool_p; case DBUS_TYPE_STRING: string_p = value; @@ -2536,8 +2537,9 @@ dbus_message_iter_append_basic (DBusMessageIter *iter, break; case DBUS_TYPE_BOOLEAN: - /* FIXME: strictly speaking we should ensure that it's in {0,1}, - * but for now, fall through */ + bool_p = value; + _dbus_return_val_if_fail (*bool_p == 0 || *bool_p == 1, FALSE); + break; default: { -- 1.7.4.1