summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog24
-rw-r--r--dbus/dbus-marshal.c31
-rw-r--r--dbus/dbus-marshal.h1
-rw-r--r--dbus/dbus-message.c279
-rw-r--r--dbus/dbus-message.h7
-rw-r--r--dbus/dbus-protocol.h32
-rw-r--r--doc/TODO14
-rw-r--r--test/break-loader.c31
-rw-r--r--test/decode-gcov.c4
9 files changed, 343 insertions, 80 deletions
diff --git a/ChangeLog b/ChangeLog
index 3be313e7..272f8406 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
2003-10-11 Havoc Pennington <hp@pobox.com>
+ * test/decode-gcov.c (function_solve_graph): make broken block
+ graph a nonfatal error since it seems to be broken. Need to debug
+ this.
+
+ * dbus/dbus-marshal.c (_dbus_type_is_valid): new function since we
+ can't just check type > INVALID < LAST anymore
+
+ * dbus/dbus-message.c (dbus_message_get_signature): new function
+ (dbus_message_has_signature): new function
+ (struct DBusMessage): add signature field (right now it isn't sent
+ over the wire, just generated on the fly)
+ (dbus_message_copy): copy the signature, and init strings to
+ proper length to avoid some reallocs
+ (dbus_message_iter_init_array_iterator): return void, since it
+ can't fail
+ (dbus_message_iter_init_dict_iterator): return void since it can't fail
+ (_dbus_message_loader_queue_messages): add silly temporary hack to
+ fill in message->signature on load
+
+ * dbus/dbus-protocol.h: change DBUS_TYPE_* values to be ASCII
+ characters, so they are relatively human-readable.
+
+2003-10-11 Havoc Pennington <hp@pobox.com>
+
* dbus/dbus-message.c (_dbus_message_test): add more test
coverage, but #if 0 for now since they uncover a bug
not fixed yet; I think in re_align_field_recurse()
diff --git a/dbus/dbus-marshal.c b/dbus/dbus-marshal.c
index cb989891..1e4992ad 100644
--- a/dbus/dbus-marshal.c
+++ b/dbus/dbus-marshal.c
@@ -1801,7 +1801,7 @@ _dbus_marshal_validate_type (const DBusString *str,
data = _dbus_string_get_const_data_len (str, pos, 1);
- if (*data > DBUS_TYPE_INVALID && *data <= DBUS_TYPE_LAST)
+ if (_dbus_type_is_valid (*data))
{
*type = *data;
if (end_pos != NULL)
@@ -2207,6 +2207,35 @@ _dbus_marshal_validate_arg (const DBusString *str,
return TRUE;
}
+/**
+ * Return #TRUE if the typecode is a valid typecode
+ *
+ * @returns #TRUE if valid
+ */
+dbus_bool_t
+_dbus_type_is_valid (int typecode)
+{
+ switch (typecode)
+ {
+ case DBUS_TYPE_NIL:
+ case DBUS_TYPE_BYTE:
+ case DBUS_TYPE_BOOLEAN:
+ case DBUS_TYPE_INT32:
+ case DBUS_TYPE_UINT32:
+ case DBUS_TYPE_INT64:
+ case DBUS_TYPE_UINT64:
+ case DBUS_TYPE_DOUBLE:
+ case DBUS_TYPE_STRING:
+ case DBUS_TYPE_NAMED:
+ case DBUS_TYPE_ARRAY:
+ case DBUS_TYPE_DICT:
+ case DBUS_TYPE_OBJECT_PATH:
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+}
/**
* If in verbose mode, print a block of binary data.
diff --git a/dbus/dbus-marshal.h b/dbus/dbus-marshal.h
index 27ded007..0e482c17 100644
--- a/dbus/dbus-marshal.h
+++ b/dbus/dbus-marshal.h
@@ -313,5 +313,6 @@ dbus_bool_t _dbus_marshal_validate_arg (const DBusString *str,
int pos,
int *end_pos);
+dbus_bool_t _dbus_type_is_valid (int typecode);
#endif /* DBUS_PROTOCOL_H */
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 18a9b50f..e23e56e1 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -103,7 +103,9 @@ struct DBusMessage
unsigned int locked : 1; /**< Message being sent, no modifications allowed. */
- DBusDataSlotList slot_list; /**< Data stored by allocated integer ID */
+ DBusDataSlotList slot_list; /**< Data stored by allocated integer ID */
+
+ DBusString signature; /**< Signature */
};
enum {
@@ -1102,6 +1104,14 @@ dbus_message_new_empty_header (void)
dbus_free (message);
return NULL;
}
+
+ if (!_dbus_string_init_preallocated (&message->signature, 4))
+ {
+ _dbus_string_free (&message->header);
+ _dbus_string_free (&message->body);
+ dbus_free (message);
+ return NULL;
+ }
return message;
}
@@ -1349,45 +1359,56 @@ dbus_message_copy (const DBusMessage *message)
retval->header_padding = message->header_padding;
retval->locked = FALSE;
- if (!_dbus_string_init (&retval->header))
+ if (!_dbus_string_init_preallocated (&retval->header,
+ _dbus_string_get_length (&message->header)))
{
dbus_free (retval);
return NULL;
}
- if (!_dbus_string_init (&retval->body))
+ if (!_dbus_string_init_preallocated (&retval->body,
+ _dbus_string_get_length (&message->body)))
{
_dbus_string_free (&retval->header);
dbus_free (retval);
return NULL;
}
- if (!_dbus_string_copy (&message->header, 0,
- &retval->header, 0))
+ if (!_dbus_string_init_preallocated (&retval->signature,
+ _dbus_string_get_length (&message->signature)))
{
_dbus_string_free (&retval->header);
_dbus_string_free (&retval->body);
dbus_free (retval);
-
return NULL;
}
+
+ if (!_dbus_string_copy (&message->header, 0,
+ &retval->header, 0))
+ goto failed_copy;
if (!_dbus_string_copy (&message->body, 0,
&retval->body, 0))
- {
- _dbus_string_free (&retval->header);
- _dbus_string_free (&retval->body);
- dbus_free (retval);
-
- return NULL;
- }
+ goto failed_copy;
+ if (!_dbus_string_copy (&message->signature, 0,
+ &retval->signature, 0))
+ goto failed_copy;
+
for (i = 0; i <= DBUS_HEADER_FIELD_LAST; i++)
{
retval->header_fields[i] = message->header_fields[i];
}
return retval;
+
+ failed_copy:
+ _dbus_string_free (&retval->header);
+ _dbus_string_free (&retval->body);
+ _dbus_string_free (&retval->signature);
+ dbus_free (retval);
+
+ return NULL;
}
@@ -1448,6 +1469,7 @@ dbus_message_unref (DBusMessage *message)
_dbus_string_free (&message->header);
_dbus_string_free (&message->body);
+ _dbus_string_free (&message->signature);
dbus_free (message);
}
@@ -2371,6 +2393,9 @@ skip_array_type (DBusMessageRealIter *iter, int pos)
return pos;
}
+/* FIXME what are these _dbus_type_is_valid() checks for?
+ * haven't we validated the message?
+ */
static int
dbus_message_iter_get_data_start (DBusMessageRealIter *iter, int *type)
{
@@ -2382,7 +2407,7 @@ dbus_message_iter_get_data_start (DBusMessageRealIter *iter, int *type)
case DBUS_MESSAGE_ITER_TYPE_MESSAGE:
data = _dbus_string_get_const_data_len (&iter->message->body,
iter->pos, 1);
- if (*data > DBUS_TYPE_INVALID && *data <= DBUS_TYPE_LAST)
+ if (_dbus_type_is_valid (*data))
*type = *data;
else
*type = DBUS_TYPE_INVALID;
@@ -2392,7 +2417,7 @@ dbus_message_iter_get_data_start (DBusMessageRealIter *iter, int *type)
case DBUS_MESSAGE_ITER_TYPE_ARRAY:
data = _dbus_string_get_const_data_len (&iter->message->body,
iter->array_type_pos, 1);
- if (*data > DBUS_TYPE_INVALID && *data <= DBUS_TYPE_LAST)
+ if (_dbus_type_is_valid (*data))
*type = *data;
else
*type = DBUS_TYPE_INVALID;
@@ -2408,7 +2433,7 @@ dbus_message_iter_get_data_start (DBusMessageRealIter *iter, int *type)
data = _dbus_string_get_const_data_len (&iter->message->body,
pos, 1);
- if (*data > DBUS_TYPE_INVALID && *data <= DBUS_TYPE_LAST)
+ if (_dbus_type_is_valid (*data))
*type = *data;
else
*type = DBUS_TYPE_INVALID;
@@ -2509,6 +2534,9 @@ dbus_message_iter_get_arg_type (DBusMessageIter *iter)
return type;
}
+/* FIXME why do we validate the typecode in here, hasn't the message
+ * already been verified?
+ */
static int
iter_get_array_type (DBusMessageRealIter *iter, int *array_type_pos)
{
@@ -2544,7 +2572,7 @@ iter_get_array_type (DBusMessageRealIter *iter, int *array_type_pos)
data = _dbus_string_get_const_data_len (&iter->message->body,
_array_type_pos, 1);
- if (*data > DBUS_TYPE_INVALID && *data <= DBUS_TYPE_LAST)
+ if (_dbus_type_is_valid (*data))
return *data;
return DBUS_TYPE_INVALID;
@@ -2851,9 +2879,8 @@ dbus_message_iter_get_double (DBusMessageIter *iter)
* @param iter the iterator
* @param array_iter pointer to an iterator to initialize
* @param array_type gets set to the type of the array elements
- * @returns #TRUE on success
*/
-dbus_bool_t
+void
dbus_message_iter_init_array_iterator (DBusMessageIter *iter,
DBusMessageIter *array_iter,
int *array_type)
@@ -2863,7 +2890,7 @@ dbus_message_iter_init_array_iterator (DBusMessageIter *iter,
int type, pos, len_pos, len, array_type_pos;
int _array_type;
- _dbus_return_val_if_fail (dbus_message_iter_check (real), FALSE);
+ _dbus_return_if_fail (dbus_message_iter_check (real));
pos = dbus_message_iter_get_data_start (real, &type);
@@ -2891,8 +2918,6 @@ dbus_message_iter_init_array_iterator (DBusMessageIter *iter,
if (array_type != NULL)
*array_type = _array_type;
-
- return TRUE;
}
@@ -2903,9 +2928,8 @@ dbus_message_iter_init_array_iterator (DBusMessageIter *iter,
*
* @param iter the iterator
* @param dict_iter pointer to an iterator to initialize
- * @returns #TRUE on success
*/
-dbus_bool_t
+void
dbus_message_iter_init_dict_iterator (DBusMessageIter *iter,
DBusMessageIter *dict_iter)
{
@@ -2913,7 +2937,7 @@ dbus_message_iter_init_dict_iterator (DBusMessageIter *iter,
DBusMessageRealIter *dict_real = (DBusMessageRealIter *)dict_iter;
int type, pos, len_pos, len;
- _dbus_return_val_if_fail (dbus_message_iter_check (real), FALSE);
+ _dbus_return_if_fail (dbus_message_iter_check (real));
pos = dbus_message_iter_get_data_start (real, &type);
@@ -2934,8 +2958,6 @@ dbus_message_iter_init_dict_iterator (DBusMessageIter *iter,
dict_real->container_start = pos;
dict_real->container_length_pos = len_pos;
dict_real->wrote_dict_key = 0;
-
- return TRUE;
}
/**
@@ -3324,8 +3346,14 @@ dbus_message_iter_append_type (DBusMessageRealIter *iter,
switch (iter->type)
{
case DBUS_MESSAGE_ITER_TYPE_MESSAGE:
+ if (!_dbus_string_append_byte (&iter->message->signature, type))
+ return FALSE;
+
if (!_dbus_string_append_byte (&iter->message->body, type))
- return FALSE;
+ {
+ _dbus_string_shorten (&iter->message->signature, 1);
+ return FALSE;
+ }
break;
case DBUS_MESSAGE_ITER_TYPE_ARRAY:
@@ -3346,7 +3374,7 @@ dbus_message_iter_append_type (DBusMessageRealIter *iter,
}
if (!_dbus_string_append_byte (&iter->message->body, type))
- return FALSE;
+ return FALSE;
break;
@@ -3783,10 +3811,18 @@ append_array_type (DBusMessageRealIter *real,
{
if (array_type_pos != NULL)
*array_type_pos = _dbus_string_get_length (&real->message->body);
+
+
+ if (!_dbus_string_append_byte (&real->message->signature, element_type))
+ {
+ _dbus_string_set_length (&real->message->body, real->pos);
+ return FALSE;
+ }
/* Append element type */
if (!_dbus_string_append_byte (&real->message->body, element_type))
{
+ _dbus_string_shorten (&real->message->signature, 1);
_dbus_string_set_length (&real->message->body, real->pos);
return FALSE;
}
@@ -3796,7 +3832,10 @@ append_array_type (DBusMessageRealIter *real,
if (element_type != DBUS_TYPE_ARRAY &&
!array_iter_type_mark_done (real))
- return FALSE;
+ {
+ _dbus_string_shorten (&real->message->signature, 1);
+ return FALSE;
+ }
}
return TRUE;
@@ -3881,10 +3920,10 @@ dbus_message_iter_append_dict (DBusMessageIter *iter,
int len_pos;
_dbus_return_val_if_fail (dbus_message_iter_append_check (real), FALSE);
-
+
if (!dbus_message_iter_append_type (real, DBUS_TYPE_DICT))
- return FALSE;
-
+ return FALSE;
+
len_pos = _DBUS_ALIGN_VALUE (_dbus_string_get_length (&real->message->body), sizeof (dbus_uint32_t));
/* Empty length for now, backfill later */
@@ -4258,6 +4297,29 @@ dbus_message_get_sender (DBusMessage *message)
NULL);
}
+/**
+ * Gets the type signature of the message, i.e. the arguments in the
+ * message payload. The signature includes only "in" arguments for
+ * #DBUS_MESSAGE_TYPE_METHOD_CALL and only "out" arguments for
+ * #DBUS_MESSAGE_TYPE_METHOD_RETURN, so is slightly different from
+ * what you might expect (it does not include the signature of the
+ * entire C++-style method).
+ *
+ * The signature is a string made up of type codes such
+ * as #DBUS_TYPE_STRING. The string is terminated with nul
+ * (nul is also the value of #DBUS_TYPE_INVALID).
+ *
+ * @param message the message
+ * @returns the type signature
+ */
+const char*
+dbus_message_get_signature (DBusMessage *message)
+{
+ _dbus_return_val_if_fail (message != NULL, NULL);
+
+ return _dbus_string_get_const_data (&message->signature);
+}
+
static dbus_bool_t
_dbus_message_has_type_interface_member (DBusMessage *message,
int type,
@@ -4419,7 +4481,8 @@ dbus_message_has_sender (DBusMessage *message,
{
const char *s;
- _dbus_assert (service != NULL);
+ _dbus_return_val_if_fail (message != NULL, FALSE);
+ _dbus_return_val_if_fail (service != NULL, FALSE);
s = dbus_message_get_sender (message);
@@ -4430,6 +4493,25 @@ dbus_message_has_sender (DBusMessage *message,
}
/**
+ * Checks whether the message has the given signature;
+ * see dbus_message_get_signature() for more details on
+ * what the signature looks like.
+ *
+ * @param message the message
+ * @param signature typecode array
+ * @returns #TRUE if message has the given signature
+*/
+dbus_bool_t
+dbus_message_has_signature (DBusMessage *message,
+ const char *signature)
+{
+ _dbus_return_val_if_fail (message != NULL, FALSE);
+ _dbus_return_val_if_fail (signature != NULL, FALSE);
+
+ return _dbus_string_equal_c_str (&message->signature, signature);
+}
+
+/**
* Sets a #DBusError based on the contents of the given
* message. The error is only set if the message
* is an error message, as in DBUS_MESSAGE_TYPE_ERROR.
@@ -5198,6 +5280,60 @@ _dbus_message_loader_queue_messages (DBusMessageLoader *loader)
message->byte_order,
CLIENT_SERIAL_OFFSET,
NULL);
+
+ /* Fill in signature (FIXME should do this during validation,
+ * but I didn't want to spend time on it since we want to change
+ * the wire format to contain the signature anyway)
+ */
+ {
+ DBusMessageIter iter;
+
+ dbus_message_iter_init (message, &iter);
+
+ do
+ {
+ int t;
+
+ t = dbus_message_iter_get_arg_type (&iter);
+ if (t == DBUS_TYPE_INVALID)
+ break;
+
+ if (!_dbus_string_append_byte (&message->signature,
+ t))
+ {
+ _dbus_verbose ("failed to append type byte to signature\n");
+ _dbus_list_remove_last (&loader->messages, message);
+ dbus_message_unref (message);
+ return FALSE;
+ }
+
+ if (t == DBUS_TYPE_ARRAY)
+ {
+ DBusMessageIter child_iter;
+ int array_type = t;
+
+ child_iter = iter;
+
+ while (array_type == DBUS_TYPE_ARRAY)
+ {
+ DBusMessageIter parent_iter = child_iter;
+ dbus_message_iter_init_array_iterator (&parent_iter,
+ &child_iter,
+ &array_type);
+
+ if (!_dbus_string_append_byte (&message->signature,
+ array_type))
+ {
+ _dbus_verbose ("failed to append array type byte to signature\n");
+ _dbus_list_remove_last (&loader->messages, message);
+ dbus_message_unref (message);
+ return FALSE;
+ }
+ }
+ }
+ }
+ while (dbus_message_iter_next (&iter));
+ }
_dbus_verbose ("Loaded message %p\n", message);
}
@@ -5512,8 +5648,7 @@ message_iter_test (DBusMessage *message)
_dbus_assert_not_reached ("Array type not double");
- if (!dbus_message_iter_init_array_iterator (&iter, &array, NULL))
- _dbus_assert_not_reached ("Array init failed");
+ dbus_message_iter_init_array_iterator (&iter, &array, NULL);
if (dbus_message_iter_get_arg_type (&array) != DBUS_TYPE_DOUBLE)
_dbus_assert_not_reached ("Argument type isn't double");
@@ -5542,8 +5677,7 @@ message_iter_test (DBusMessage *message)
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_DICT)
_dbus_assert_not_reached ("not dict type");
- if (!dbus_message_iter_init_dict_iterator (&iter, &dict))
- _dbus_assert_not_reached ("dict iter failed");
+ dbus_message_iter_init_dict_iterator (&iter, &dict);
str = dbus_message_iter_get_dict_key (&dict);
if (str == NULL || strcmp (str, "test") != 0)
@@ -5572,8 +5706,7 @@ message_iter_test (DBusMessage *message)
if (dbus_message_iter_get_array_type (&dict) != DBUS_TYPE_ARRAY)
_dbus_assert_not_reached ("Array type not array");
- if (!dbus_message_iter_init_array_iterator (&dict, &array, NULL))
- _dbus_assert_not_reached ("Array init failed");
+ dbus_message_iter_init_array_iterator (&dict, &array, NULL);
if (dbus_message_iter_get_arg_type (&array) != DBUS_TYPE_ARRAY)
_dbus_assert_not_reached ("Argument type isn't array");
@@ -5581,8 +5714,7 @@ message_iter_test (DBusMessage *message)
if (dbus_message_iter_get_array_type (&array) != DBUS_TYPE_INT32)
_dbus_assert_not_reached ("Array type not int32");
- if (!dbus_message_iter_init_array_iterator (&array, &array2, NULL))
- _dbus_assert_not_reached ("Array init failed");
+ dbus_message_iter_init_array_iterator (&array, &array2, NULL);
if (dbus_message_iter_get_arg_type (&array2) != DBUS_TYPE_INT32)
_dbus_assert_not_reached ("Argument type isn't int32");
@@ -5727,11 +5859,7 @@ check_message_handling_type (DBusMessageIter *iter,
{
int array_type;
- if (!dbus_message_iter_init_array_iterator (iter, &child_iter, &array_type))
- {
- _dbus_warn ("Failed to init array iterator\n");
- return FALSE;
- }
+ dbus_message_iter_init_array_iterator (iter, &child_iter, &array_type);
while (dbus_message_iter_has_next (&child_iter))
{
@@ -5751,11 +5879,7 @@ check_message_handling_type (DBusMessageIter *iter,
int entry_type;
char *key;
- if (!dbus_message_iter_init_dict_iterator (iter, &child_iter))
- {
- _dbus_warn ("Failed to init dict iterator\n");
- return FALSE;
- }
+ dbus_message_iter_init_dict_iterator (iter, &child_iter);
while ((entry_type = dbus_message_iter_get_arg_type (&child_iter)) != DBUS_TYPE_INVALID)
{
@@ -6479,8 +6603,7 @@ verify_test_message (DBusMessage *message)
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_DICT)
_dbus_assert_not_reached ("not dict type");
- if (!dbus_message_iter_init_dict_iterator (&iter, &dict))
- _dbus_assert_not_reached ("dict iter failed");
+ dbus_message_iter_init_dict_iterator (&iter, &dict);
our_str = dbus_message_iter_get_dict_key (&dict);
if (our_str == NULL || strcmp (our_str, "test") != 0)
@@ -6546,6 +6669,8 @@ _dbus_message_test (const char *test_data_dir)
const double our_double_array[] = { 0.1234, 9876.54321, -300.0 };
const unsigned char our_byte_array[] = { 'a', 'b', 'c', 234 };
const unsigned char our_boolean_array[] = { TRUE, FALSE, TRUE, TRUE, FALSE };
+ char sig[64];
+ const char *s;
_dbus_assert (sizeof (DBusMessageRealIter) <= sizeof (DBusMessageIter));
@@ -6671,12 +6796,53 @@ _dbus_message_test (const char *test_data_dir)
dbus_message_iter_append_dict_key (&child_iter, "test");
dbus_message_iter_append_uint32 (&child_iter, 0xDEADBEEF);
dbus_message_iter_append_uint32 (&iter, 0xCAFEBABE);
+
+ i = 0;
+ sig[i++] = DBUS_TYPE_INT32;
+#ifdef DBUS_HAVE_INT64
+ sig[i++] = DBUS_TYPE_INT64;
+ sig[i++] = DBUS_TYPE_UINT64;
+#endif
+ sig[i++] = DBUS_TYPE_STRING;
+ sig[i++] = DBUS_TYPE_DOUBLE;
+ sig[i++] = DBUS_TYPE_BOOLEAN;
+ sig[i++] = DBUS_TYPE_ARRAY;
+ sig[i++] = DBUS_TYPE_UINT32;
+ sig[i++] = DBUS_TYPE_ARRAY;
+ sig[i++] = DBUS_TYPE_INT32;
+#ifdef DBUS_HAVE_INT64
+ sig[i++] = DBUS_TYPE_ARRAY;
+ sig[i++] = DBUS_TYPE_UINT64;
+ sig[i++] = DBUS_TYPE_ARRAY;
+ sig[i++] = DBUS_TYPE_INT64;
+#endif
+ sig[i++] = DBUS_TYPE_ARRAY;
+ sig[i++] = DBUS_TYPE_STRING;
+ sig[i++] = DBUS_TYPE_ARRAY;
+ sig[i++] = DBUS_TYPE_DOUBLE;
+ sig[i++] = DBUS_TYPE_ARRAY;
+ sig[i++] = DBUS_TYPE_BYTE;
+ sig[i++] = DBUS_TYPE_ARRAY;
+ sig[i++] = DBUS_TYPE_BOOLEAN;
+ sig[i++] = DBUS_TYPE_DICT;
+ sig[i++] = DBUS_TYPE_UINT32;
+ sig[i++] = DBUS_TYPE_INVALID;
+
+ _dbus_assert (i < (int) _DBUS_N_ELEMENTS (sig));
_dbus_verbose_bytes_of_string (&message->header, 0,
_dbus_string_get_length (&message->header));
_dbus_verbose_bytes_of_string (&message->body, 0,
_dbus_string_get_length (&message->body));
-
+
+ _dbus_verbose ("Signature expected \"%s\" actual \"%s\"\n",
+ sig, dbus_message_get_signature (message));
+
+ s = dbus_message_get_signature (message);
+
+ _dbus_assert (dbus_message_has_signature (message, sig));
+ _dbus_assert (strcmp (s, sig) == 0);
+
verify_test_message (message);
copy = dbus_message_copy (message);
@@ -6691,6 +6857,9 @@ _dbus_message_test (const char *test_data_dir)
_dbus_assert (_dbus_string_get_length (&message->body) ==
_dbus_string_get_length (&copy->body));
+ _dbus_assert (_dbus_string_get_length (&message->signature) ==
+ _dbus_string_get_length (&copy->signature));
+
verify_test_message (copy);
name1 = dbus_message_get_interface (message);
diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h
index bfaf2f0d..235bec6d 100644
--- a/dbus/dbus-message.h
+++ b/dbus/dbus-message.h
@@ -96,6 +96,7 @@ const char* dbus_message_get_destination (DBusMessage *message);
dbus_bool_t dbus_message_set_sender (DBusMessage *message,
const char *sender);
const char* dbus_message_get_sender (DBusMessage *message);
+const char* dbus_message_get_signature (DBusMessage *message);
void dbus_message_set_no_reply (DBusMessage *message,
dbus_bool_t no_reply);
dbus_bool_t dbus_message_get_no_reply (DBusMessage *message);
@@ -111,6 +112,8 @@ dbus_bool_t dbus_message_has_destination (DBusMessage *message,
const char *service);
dbus_bool_t dbus_message_has_sender (DBusMessage *message,
const char *service);
+dbus_bool_t dbus_message_has_signature (DBusMessage *message,
+ const char *signature);
dbus_uint32_t dbus_message_get_serial (DBusMessage *message);
dbus_bool_t dbus_message_set_reply_serial (DBusMessage *message,
dbus_uint32_t reply_serial);
@@ -166,10 +169,10 @@ dbus_bool_t dbus_message_iter_get_named (DBusMessageIter *iter,
unsigned char **value,
int *len);
-dbus_bool_t dbus_message_iter_init_array_iterator (DBusMessageIter *iter,
+void dbus_message_iter_init_array_iterator (DBusMessageIter *iter,
DBusMessageIter *array_iter,
int *array_type);
-dbus_bool_t dbus_message_iter_init_dict_iterator (DBusMessageIter *iter,
+void dbus_message_iter_init_dict_iterator (DBusMessageIter *iter,
DBusMessageIter *dict_iter);
dbus_bool_t dbus_message_iter_get_byte_array (DBusMessageIter *iter,
unsigned char **value,
diff --git a/dbus/dbus-protocol.h b/dbus/dbus-protocol.h
index 549ef0e5..94bb4dd9 100644
--- a/dbus/dbus-protocol.h
+++ b/dbus/dbus-protocol.h
@@ -40,22 +40,22 @@ extern "C" {
#define DBUS_MAJOR_PROTOCOL_VERSION 0
/* Data types */
-#define DBUS_TYPE_INVALID 0
-#define DBUS_TYPE_NIL 1
-#define DBUS_TYPE_BYTE 2
-#define DBUS_TYPE_BOOLEAN 3
-#define DBUS_TYPE_INT32 4
-#define DBUS_TYPE_UINT32 5
-#define DBUS_TYPE_INT64 6
-#define DBUS_TYPE_UINT64 7
-#define DBUS_TYPE_DOUBLE 8
-#define DBUS_TYPE_STRING 9
-#define DBUS_TYPE_NAMED 10
-#define DBUS_TYPE_ARRAY 11
-#define DBUS_TYPE_DICT 12
-#define DBUS_TYPE_OBJECT_PATH 13
-
-#define DBUS_TYPE_LAST DBUS_TYPE_OBJECT_PATH
+#define DBUS_TYPE_INVALID ((int) '\0')
+#define DBUS_TYPE_NIL ((int) 'v')
+#define DBUS_TYPE_BYTE ((int) 'y')
+#define DBUS_TYPE_BOOLEAN ((int) 'b')
+#define DBUS_TYPE_INT32 ((int) 'i')
+#define DBUS_TYPE_UINT32 ((int) 'u')
+#define DBUS_TYPE_INT64 ((int) 'x')
+#define DBUS_TYPE_UINT64 ((int) 't')
+#define DBUS_TYPE_DOUBLE ((int) 'd')
+#define DBUS_TYPE_STRING ((int) 's')
+#define DBUS_TYPE_NAMED ((int) 'n')
+#define DBUS_TYPE_ARRAY ((int) 'a')
+#define DBUS_TYPE_DICT ((int) 'c')
+#define DBUS_TYPE_OBJECT_PATH ((int) 'o')
+
+#define DBUS_NUMBER_OF_TYPES (13)
/* Max length in bytes of a service or interface or member name */
#define DBUS_MAXIMUM_NAME_LENGTH 256
diff --git a/doc/TODO b/doc/TODO
index 43d5ff5c..8c578882 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -93,3 +93,17 @@
- re_align_field_recurse() in dbus-message.c is broken because it
crashes on some types of header field values. security problem.
+
+ - the system daemon has to be able to reload changes to the
+ security policy without restarting, because apps won't
+ be coded to handle it restarting
+
+ - modify the wire protocol to keep the args signature separate
+ from the args themselves. Make the name of TYPE_NAMED part
+ of the type signature, rather than part of the value.
+ Then you have the full typecheck in a single string.
+
+ - rename TYPE_NAMED to TYPE_CUSTOM, probably a clearer name.
+
+ - dbus_message_iter_init_array_iterator has "iter" and "iterator"
+ in the same function name
diff --git a/test/break-loader.c b/test/break-loader.c
index 3771d7cc..5a0c61f2 100644
--- a/test/break-loader.c
+++ b/test/break-loader.c
@@ -392,6 +392,31 @@ randomly_set_extreme_ints (const DBusString *orig_data,
extreme_ints[which]);
}
+static int
+random_type (void)
+{
+ const char types[] = {
+ DBUS_TYPE_INVALID,
+ DBUS_TYPE_NIL,
+ DBUS_TYPE_BYTE,
+ DBUS_TYPE_BOOLEAN,
+ DBUS_TYPE_INT32,
+ DBUS_TYPE_UINT32,
+ DBUS_TYPE_INT64,
+ DBUS_TYPE_UINT64,
+ DBUS_TYPE_DOUBLE,
+ DBUS_TYPE_STRING,
+ DBUS_TYPE_NAMED,
+ DBUS_TYPE_ARRAY,
+ DBUS_TYPE_DICT,
+ DBUS_TYPE_OBJECT_PATH
+ };
+
+ _dbus_assert (_DBUS_N_ELEMENTS (types) == DBUS_NUMBER_OF_TYPES + 1);
+
+ return types[ random_int_in_range (0, _DBUS_N_ELEMENTS (types)) ];
+}
+
static void
randomly_change_one_type (const DBusString *orig_data,
DBusString *mutated)
@@ -420,11 +445,9 @@ randomly_change_one_type (const DBusString *orig_data,
{
int b;
b = _dbus_string_get_byte (mutated, i);
- if (b > DBUS_TYPE_INVALID && b <= DBUS_TYPE_LAST)
+ if (_dbus_type_is_valid (b))
{
- _dbus_string_set_byte (mutated, i,
- random_int_in_range (DBUS_TYPE_INVALID,
- DBUS_TYPE_LAST + 1));
+ _dbus_string_set_byte (mutated, i, random_type ());
return;
}
++i;
diff --git a/test/decode-gcov.c b/test/decode-gcov.c
index 29f061f7..9eb8d7be 100644
--- a/test/decode-gcov.c
+++ b/test/decode-gcov.c
@@ -831,10 +831,10 @@ function_solve_graph (Function *func)
{
if (block_graph[i].succ_count || block_graph[i].pred_count)
{
- fprintf (stderr, "Block graph solved incorrectly\n");
+ fprintf (stderr, "WARNING: Block graph solved incorrectly\n");
fprintf (stderr, " block %d has succ_count = %d pred_count = %d\n",
i, (int) block_graph[i].succ_count, (int) block_graph[i].pred_count);
- exit (1);
+ fprintf (stderr, " this error reflects a bug in decode-gcov.c\n");
}
}
}