summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-marshal.c36
-rw-r--r--dbus/dbus-message-builder.c1
-rw-r--r--dbus/dbus-message.c20
-rw-r--r--dbus/dbus-message.h6
4 files changed, 51 insertions, 12 deletions
diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c
index 37a97515..b9b2cf52 100644
--- a/dbus/dbus-marshal.c
+++ b/dbus/dbus-marshal.c
@@ -1109,9 +1109,20 @@ _dbus_marshal_validate_arg (const DBusString *str,
break;
case DBUS_TYPE_BOOLEAN:
+ {
+ unsigned char c;
+
+ c = _dbus_string_get_byte (str, pos + 1);
+
+ if (c != 0 && c != 1)
+ {
+ _dbus_verbose ("boolean value must be either 0 or 1, not %d\n", c);
+ return FALSE;
+ }
+
*end_pos = pos + 2;
break;
-
+ }
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
{
@@ -1162,6 +1173,29 @@ _dbus_marshal_validate_arg (const DBusString *str,
break;
case DBUS_TYPE_BOOLEAN_ARRAY:
+ {
+ int len, i;
+
+ len = demarshal_and_validate_len (str, byte_order, pos + 1, &pos);
+ if (len < 0)
+ return FALSE;
+
+ i = 0;
+ while (i < len)
+ {
+ unsigned char c = _dbus_string_get_byte (str, pos + i);
+
+ if (c != 0 && c != 1)
+ {
+ _dbus_verbose ("boolean value must be either 0 or 1, not %d (pos %d)\n", c, pos);
+ return FALSE;
+ }
+
+ i++;
+ }
+ *end_pos = pos + len;
+ break;
+ }
case DBUS_TYPE_BYTE_ARRAY:
{
int len;
diff --git a/dbus/dbus-message-builder.c b/dbus/dbus-message-builder.c
index 9526a2e1..dea50d7f 100644
--- a/dbus/dbus-message-builder.c
+++ b/dbus/dbus-message-builder.c
@@ -661,7 +661,6 @@ _dbus_message_data_load (DBusString *dest,
while (i < _dbus_string_get_length (&line))
{
_dbus_string_skip_blank (&line, i, &i);
- printf ("i is: %d\n", i);
if (_dbus_string_find_to (&line, i, i + 5,
"false", NULL))
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 0d664916..584acc7e 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -1180,7 +1180,7 @@ dbus_message_append_nil (DBusMessage *message)
*/
dbus_bool_t
dbus_message_append_boolean (DBusMessage *message,
- unsigned char value)
+ dbus_bool_t value)
{
_dbus_assert (!message->locked);
@@ -1305,9 +1305,9 @@ dbus_message_append_string (DBusMessage *message,
* @returns #TRUE on success
*/
dbus_bool_t
-dbus_message_append_boolean_array (DBusMessage *message,
- unsigned char *value,
- int len)
+dbus_message_append_boolean_array (DBusMessage *message,
+ unsigned const char *value,
+ int len)
{
_dbus_assert (!message->locked);
@@ -1543,9 +1543,9 @@ dbus_message_get_args_valist (DBusMessage *message,
break;
case DBUS_TYPE_BOOLEAN:
{
- unsigned char *ptr;
+ dbus_bool_t *ptr;
- ptr = va_arg (var_args, unsigned char *);
+ ptr = va_arg (var_args, dbus_bool_t *);
*ptr = dbus_message_iter_get_boolean (iter);
break;
@@ -1854,7 +1854,7 @@ dbus_message_iter_get_string (DBusMessageIter *iter)
* @param iter the message iter
* @returns the string
*/
-unsigned char
+dbus_bool_t
dbus_message_iter_get_boolean (DBusMessageIter *iter)
{
unsigned char value;
@@ -3421,6 +3421,7 @@ _dbus_message_test (const char *test_data_dir)
dbus_int32_t our_int;
char *our_str;
double our_double;
+ dbus_bool_t our_bool;
/* Test the vararg functions */
message = dbus_message_new ("org.freedesktop.DBus.Test", "testMessage");
@@ -3429,6 +3430,7 @@ _dbus_message_test (const char *test_data_dir)
DBUS_TYPE_INT32, -0x12345678,
DBUS_TYPE_STRING, "Test string",
DBUS_TYPE_DOUBLE, 3.14159,
+ DBUS_TYPE_BOOLEAN, TRUE,
0);
_dbus_verbose_bytes_of_string (&message->header, 0,
_dbus_string_get_length (&message->header));
@@ -3439,6 +3441,7 @@ _dbus_message_test (const char *test_data_dir)
DBUS_TYPE_INT32, &our_int,
DBUS_TYPE_STRING, &our_str,
DBUS_TYPE_DOUBLE, &our_double,
+ DBUS_TYPE_BOOLEAN, &our_bool,
0) != DBUS_RESULT_SUCCESS)
_dbus_assert_not_reached ("Could not get arguments");
@@ -3451,6 +3454,9 @@ _dbus_message_test (const char *test_data_dir)
if (strcmp (our_str, "Test string") != 0)
_dbus_assert_not_reached ("strings differ!");
+ if (!our_bool)
+ _dbus_assert_not_reached ("booleans differ");
+
dbus_free (our_str);
dbus_message_unref (message);
diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h
index ecb7407e..bb2b620e 100644
--- a/dbus/dbus-message.h
+++ b/dbus/dbus-message.h
@@ -67,7 +67,7 @@ dbus_bool_t dbus_message_append_args_valist (DBusMessage *message,
va_list var_args);
dbus_bool_t dbus_message_append_nil (DBusMessage *message);
dbus_bool_t dbus_message_append_boolean (DBusMessage *message,
- unsigned char value);
+ dbus_bool_t value);
dbus_bool_t dbus_message_append_int32 (DBusMessage *message,
dbus_int32_t value);
dbus_bool_t dbus_message_append_uint32 (DBusMessage *message,
@@ -77,7 +77,7 @@ dbus_bool_t dbus_message_append_double (DBusMessage *message,
dbus_bool_t dbus_message_append_string (DBusMessage *message,
const char *value);
dbus_bool_t dbus_message_append_boolean_array (DBusMessage *message,
- unsigned char *value,
+ unsigned const char *value,
int len);
dbus_bool_t dbus_message_append_int32_array (DBusMessage *message,
const dbus_int32_t *value,
@@ -111,7 +111,7 @@ void dbus_message_iter_unref (DBusMessageIter *iter);
dbus_bool_t dbus_message_iter_has_next (DBusMessageIter *iter);
dbus_bool_t dbus_message_iter_next (DBusMessageIter *iter);
int dbus_message_iter_get_arg_type (DBusMessageIter *iter);
-unsigned char dbus_message_iter_get_boolean (DBusMessageIter *iter);
+dbus_bool_t dbus_message_iter_get_boolean (DBusMessageIter *iter);
int dbus_message_iter_get_int32 (DBusMessageIter *iter);
int dbus_message_iter_get_uint32 (DBusMessageIter *iter);
double dbus_message_iter_get_double (DBusMessageIter *iter);