-/**
- * 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.
- * The name of the error is set to the name of the message,
- * and the error message is set to the first argument
- * if the argument exists and is a string.
- *
- * The return value indicates whether the error was set (the error is
- * set if and only if the message is an error message).
- * So you can check for an error reply and convert it to DBusError
- * in one go.
- *
- * @param error the error to set
- * @param message the message to set it from
- * @returns #TRUE if dbus_message_get_is_error() returns #TRUE for the message
- */
-dbus_bool_t
-dbus_set_error_from_message (DBusError *error,
- DBusMessage *message)
-{
- char *str;
-
- _dbus_return_val_if_fail (message != NULL, FALSE);
- _dbus_return_val_if_error_is_set (error, FALSE);
-
- if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR)
- return FALSE;
-
- str = NULL;
- dbus_message_get_args (message, NULL,
- DBUS_TYPE_STRING, &str,
- DBUS_TYPE_INVALID);
-
- dbus_set_error (error, dbus_message_get_error_name (message),
- str ? "%s" : NULL, str);
-
- dbus_free (str);
-
- return TRUE;
-}
-
-/** @} */
-
-/**
- * @addtogroup DBusMessageInternals
- *
- * @{
- */
-/**
- * @typedef DBusMessageLoader
- *
- * The DBusMessageLoader object encapsulates the process of converting
- * a byte stream into a series of DBusMessage. It buffers the incoming
- * bytes as efficiently as possible, and generates a queue of
- * messages. DBusMessageLoader is typically used as part of a
- * DBusTransport implementation. The DBusTransport then hands off
- * the loaded messages to a DBusConnection, making the messages
- * visible to the application.
- *
- * @todo write tests for break-loader that a) randomly delete header
- * fields and b) set string fields to zero-length and other funky
- * values.
- *
- */
-
-/* we definitely use signed ints for sizes, so don't exceed
- * _DBUS_INT_MAX; and add 16 for paranoia, since a message
- * over 128M is pretty nuts anyhow.
- */
-
-/**
- * The maximum sane message size.
- */
-#define MAX_SANE_MESSAGE_SIZE (_DBUS_INT_MAX/16)
-
-/**
- * Implementation details of DBusMessageLoader.
- * All members are private.
- */
-struct DBusMessageLoader
-{
- int refcount; /**< Reference count. */
-
- DBusString data; /**< Buffered data */
-
- DBusList *messages; /**< Complete messages. */
-
- long max_message_size; /**< Maximum size of a message */
-
- unsigned int buffer_outstanding : 1; /**< Someone is using the buffer to read */
-
- unsigned int corrupted : 1; /**< We got broken data, and are no longer working */
-};
-
-/**
- * The initial buffer size of the message loader.
- *
- * @todo this should be based on min header size plus some average
- * body size, or something. Or rather, the min header size only, if we
- * want to try to read only the header, store that in a DBusMessage,
- * then read only the body and store that, etc., depends on
- * how we optimize _dbus_message_loader_get_buffer() and what
- * the exact message format is.
- */
-#define INITIAL_LOADER_DATA_LEN 32
-
-/**
- * Creates a new message loader. Returns #NULL if memory can't
- * be allocated.
- *
- * @returns new loader, or #NULL.
- */
-DBusMessageLoader*
-_dbus_message_loader_new (void)
-{
- DBusMessageLoader *loader;
-
- loader = dbus_new0 (DBusMessageLoader, 1);
- if (loader == NULL)
- return NULL;
-
- loader->refcount = 1;
-
- /* Try to cap message size at something that won't *totally* hose
- * the system if we have a couple of them.
- */
- loader->max_message_size = _DBUS_ONE_MEGABYTE * 32;
-
- if (!_dbus_string_init (&loader->data))
- {
- dbus_free (loader);
- return NULL;
- }
-
- /* preallocate the buffer for speed, ignore failure */
- _dbus_string_set_length (&loader->data, INITIAL_LOADER_DATA_LEN);
- _dbus_string_set_length (&loader->data, 0);
-
- return loader;
-}
-
-/**
- * Increments the reference count of the loader.
- *
- * @param loader the loader.
- * @returns the loader
- */
-DBusMessageLoader *
-_dbus_message_loader_ref (DBusMessageLoader *loader)
-{
- loader->refcount += 1;
-
- return loader;
-}
-
-/**
- * Decrements the reference count of the loader and finalizes the
- * loader when the count reaches zero.
- *
- * @param loader the loader.
- */
-void
-_dbus_message_loader_unref (DBusMessageLoader *loader)
-{
- loader->refcount -= 1;
- if (loader->refcount == 0)
- {
- _dbus_list_foreach (&loader->messages,
- (DBusForeachFunction) dbus_message_unref,
- NULL);
- _dbus_list_clear (&loader->messages);
- _dbus_string_free (&loader->data);
- dbus_free (loader);
- }
-}
-
-/**
- * Gets the buffer to use for reading data from the network. Network
- * data is read directly into an allocated buffer, which is then used
- * in the DBusMessage, to avoid as many extra memcpy's as possible.
- * The buffer must always be returned immediately using
- * _dbus_message_loader_return_buffer(), even if no bytes are
- * successfully read.
- *
- * @todo this function can be a lot more clever. For example
- * it can probably always return a buffer size to read exactly
- * the body of the next message, thus avoiding any memory wastage
- * or reallocs.
- *
- * @todo we need to enforce a max length on strings in header fields.
- *
- * @param loader the message loader.
- * @param buffer the buffer
- */
-void
-_dbus_message_loader_get_buffer (DBusMessageLoader *loader,
- DBusString **buffer)
-{
- _dbus_assert (!loader->buffer_outstanding);
-
- *buffer = &loader->data;
-
- loader->buffer_outstanding = TRUE;
-}
-
-/**
- * The smallest header size that can occur.
- * (It won't be valid)
- */
-#define DBUS_MINIMUM_HEADER_SIZE 16
-
-static dbus_bool_t
-decode_string_field (const DBusString *data,
- int field,
- HeaderField *header_field,
- DBusString *field_data,
- int pos,
- int type)
-{
- int string_data_pos;
-
- _dbus_assert (header_field != NULL);
- _dbus_assert (field_data != NULL);
-
- if (header_field->name_offset >= 0)
- {
- _dbus_verbose ("%s field provided twice\n",
- _dbus_header_field_to_string (field));
- return FALSE;
- }
-
- if (type != DBUS_TYPE_STRING)
- {
- _dbus_verbose ("%s field has wrong type %s\n",
- _dbus_header_field_to_string (field),
- _dbus_type_to_string (type));
- return FALSE;
- }
-
- /* skip padding after typecode, skip string length;
- * we assume that the string arg has already been validated
- * for sanity and UTF-8
- */
- string_data_pos = _DBUS_ALIGN_VALUE (pos, 4) + 4;
- _dbus_assert (string_data_pos < _dbus_string_get_length (data));
-
- _dbus_string_init_const (field_data,
- _dbus_string_get_const_data (data) + string_data_pos);
-
- header_field->name_offset = pos - 2;
- header_field->value_offset = _DBUS_ALIGN_VALUE (pos, 4);
-
-#if 0
- _dbus_verbose ("Found field %s at offset %d\n",
- _dbus_header_field_to_string (field),
- header_field->value_offset);
-#endif
-
- return TRUE;
-}
-
-/* FIXME because the service/interface/member/error names are already
- * validated to be in the particular ASCII subset, UTF-8 validating
- * them could be skipped as a probably-interesting optimization.
- * The UTF-8 validation definitely shows up in profiles.
- */
-static dbus_bool_t
-decode_header_data (const DBusString *data,
- int header_len,
- int byte_order,
- int message_type,
- HeaderField fields[DBUS_HEADER_FIELD_LAST + 1],
- int *message_padding)
-{
- DBusString field_data;
- int pos, new_pos;
- int i;
- int field;
- int type;
-
- if (header_len < 16)
- {
- _dbus_verbose ("Header length %d is too short\n", header_len);
- return FALSE;
- }
-
- i = 0;
- while (i <= DBUS_HEADER_FIELD_LAST)
- {
- fields[i].name_offset = -1;
- fields[i].value_offset = -1;
- ++i;
- }
-
- pos = 16;
- while (pos < header_len)
- {
- field = _dbus_string_get_byte (data, pos);
- if (field == DBUS_HEADER_FIELD_INVALID)
- break; /* Must be padding */
- pos++;
-
- if (!_dbus_marshal_validate_type (data, pos, &type, &pos))
- {
- _dbus_verbose ("Failed to validate type of named header field pos = %d\n",
- pos);
- return FALSE;
- }
-
- if (!_dbus_marshal_validate_arg (data, byte_order, 0, type, -1, pos, &new_pos))
- {
- _dbus_verbose ("Failed to validate argument to named header field pos = %d\n",
- pos);
- return FALSE;
- }
-
- if (new_pos > header_len)
- {
- _dbus_verbose ("Named header field tries to extend beyond header length\n");
- return FALSE;
- }
-
- switch (field)
- {
- case DBUS_HEADER_FIELD_DESTINATION:
- if (!decode_string_field (data, field, &fields[field],
- &field_data, pos, type))
- return FALSE;
-
- if (!_dbus_string_validate_service (&field_data, 0,
- _dbus_string_get_length (&field_data)))
- {
- _dbus_verbose ("service field has invalid content \"%s\"\n",
- _dbus_string_get_const_data (&field_data));
- return FALSE;
- }
- break;
-
- case DBUS_HEADER_FIELD_INTERFACE:
- if (!decode_string_field (data, field, &fields[field],
- &field_data, pos, type))
- return FALSE;
-
- if (!_dbus_string_validate_interface (&field_data, 0,
- _dbus_string_get_length (&field_data)))
- {
- _dbus_verbose ("interface field has invalid content \"%s\"\n",
- _dbus_string_get_const_data (&field_data));
- return FALSE;
- }
-
- if (_dbus_string_equal_c_str (&field_data,
- DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL))
- {
- _dbus_verbose ("Message is on the local interface\n");
- return FALSE;
- }
- break;
-
- case DBUS_HEADER_FIELD_MEMBER:
- if (!decode_string_field (data, field, &fields[field],
- &field_data, pos, type))
- return FALSE;
-
- if (!_dbus_string_validate_member (&field_data, 0,
- _dbus_string_get_length (&field_data)))
- {
- _dbus_verbose ("member field has invalid content \"%s\"\n",
- _dbus_string_get_const_data (&field_data));
- return FALSE;
- }
- break;
-
- case DBUS_HEADER_FIELD_ERROR_NAME:
- if (!decode_string_field (data, field, &fields[field],
- &field_data, pos, type))
- return FALSE;
-
- if (!_dbus_string_validate_error_name (&field_data, 0,
- _dbus_string_get_length (&field_data)))
- {
- _dbus_verbose ("error-name field has invalid content \"%s\"\n",
- _dbus_string_get_const_data (&field_data));
- return FALSE;
- }
- break;
-
- case DBUS_HEADER_FIELD_SENDER:
- if (!decode_string_field (data, field, &fields[field],
- &field_data, pos, type))
- return FALSE;
-
- if (!_dbus_string_validate_service (&field_data, 0,
- _dbus_string_get_length (&field_data)))
- {
- _dbus_verbose ("sender-service field has invalid content \"%s\"\n",
- _dbus_string_get_const_data (&field_data));
- return FALSE;
- }
- break;
-
- case DBUS_HEADER_FIELD_PATH:
-
- /* Path was already validated as part of standard
- * type validation, since there's an OBJECT_PATH
- * type.
- */
-
- if (fields[field].name_offset >= 0)
- {
- _dbus_verbose ("path field provided twice\n");
- return FALSE;
- }
- if (type != DBUS_TYPE_OBJECT_PATH)
- {
- _dbus_verbose ("path field has wrong type\n");
- return FALSE;
- }
-
- fields[field].name_offset = pos - 2;
- fields[field].value_offset = _DBUS_ALIGN_VALUE (pos, 4);
-
- /* No forging signals from the local path */
- {
- const char *s;
- s = _dbus_string_get_const_data_len (data,
- fields[field].value_offset,
- _dbus_string_get_length (data) -
- fields[field].value_offset);
- if (strcmp (s, DBUS_PATH_ORG_FREEDESKTOP_LOCAL) == 0)
- {
- _dbus_verbose ("Message is on the local path\n");
- return FALSE;
- }
- }
-
- _dbus_verbose ("Found path at offset %d\n",
- fields[field].value_offset);
- break;
-
- case DBUS_HEADER_FIELD_REPLY_SERIAL:
- if (fields[field].name_offset >= 0)
- {
- _dbus_verbose ("reply field provided twice\n");
- return FALSE;
- }
-
- if (type != DBUS_TYPE_UINT32)
- {
- _dbus_verbose ("reply field has wrong type\n");
- return FALSE;
- }
-
- fields[field].name_offset = pos - 2;
- fields[field].value_offset = _DBUS_ALIGN_VALUE (pos, 4);
-
- _dbus_verbose ("Found reply serial %u at offset %d\n",
- _dbus_demarshal_uint32 (data,
- byte_order,
- fields[field].value_offset,
- NULL),
- fields[field].value_offset);
- break;
-
- default:
- _dbus_verbose ("Ignoring an unknown header field: %d at offset %d\n",
- field, pos);
- }
-
- pos = new_pos;
- }
-
- if (pos < header_len)
- {
- /* Alignment padding, verify that it's nul */
- if ((header_len - pos) >= 8)
- {
- _dbus_verbose ("too much header alignment padding\n");
- return FALSE;
- }
-
- if (!_dbus_string_validate_nul (data,
- pos, (header_len - pos)))
- {
- _dbus_verbose ("header alignment padding is not nul\n");
- return FALSE;
- }
- }
-
- /* Depending on message type, enforce presence of certain fields. */
- switch (message_type)
- {
- case DBUS_MESSAGE_TYPE_SIGNAL:
- case DBUS_MESSAGE_TYPE_METHOD_CALL:
- if (fields[DBUS_HEADER_FIELD_PATH].value_offset < 0)
- {
- _dbus_verbose ("No path field provided\n");
- return FALSE;
- }
- /* FIXME make this optional, only for method calls */
- if (fields[DBUS_HEADER_FIELD_INTERFACE].value_offset < 0)
- {
- _dbus_verbose ("No interface field provided\n");
- return FALSE;
- }
- if (fields[DBUS_HEADER_FIELD_MEMBER].value_offset < 0)
- {
- _dbus_verbose ("No member field provided\n");
- return FALSE;
- }
- break;
- case DBUS_MESSAGE_TYPE_ERROR:
- if (fields[DBUS_HEADER_FIELD_ERROR_NAME].value_offset < 0)
- {
- _dbus_verbose ("No error-name field provided\n");
- return FALSE;
- }
- if (fields[DBUS_HEADER_FIELD_REPLY_SERIAL].value_offset < 0)
- {
- _dbus_verbose ("No reply serial field provided in error\n");
- return FALSE;
- }
- break;
- case DBUS_MESSAGE_TYPE_METHOD_RETURN:
- if (fields[DBUS_HEADER_FIELD_REPLY_SERIAL].value_offset < 0)
- {
- _dbus_verbose ("No reply serial field provided in method return\n");
- return FALSE;
- }
- break;
- default:
- /* An unknown type, spec requires us to ignore it */
- break;
- }
-
- if (message_padding)
- *message_padding = header_len - pos;
-
- return TRUE;
-}
-
-/**
- * Returns a buffer obtained from _dbus_message_loader_get_buffer(),
- * indicating to the loader how many bytes of the buffer were filled
- * in. This function must always be called, even if no bytes were
- * successfully read.
- *
- * @param loader the loader.
- * @param buffer the buffer.
- * @param bytes_read number of bytes that were read into the buffer.
- */
-void
-_dbus_message_loader_return_buffer (DBusMessageLoader *loader,
- DBusString *buffer,
- int bytes_read)
-{
- _dbus_assert (loader->buffer_outstanding);
- _dbus_assert (buffer == &loader->data);
-
- loader->buffer_outstanding = FALSE;
-}
-
-static dbus_bool_t
-load_one_message (DBusMessageLoader *loader,
- int byte_order,
- int message_type,
- int header_len,
- int body_len)
-{
- DBusMessage *message;
- HeaderField fields[DBUS_HEADER_FIELD_LAST + 1];
- int i;
- int next_arg;
- dbus_bool_t oom;
- int header_padding;
-
- message = NULL;
- oom = FALSE;
-
-#if 0
- _dbus_verbose_bytes_of_string (&loader->data, 0, header_len /* + body_len */);
-#endif
-
- if (!decode_header_data (&loader->data,
- header_len, byte_order,
- message_type,
- fields, &header_padding))
- {
- _dbus_verbose ("Header was invalid\n");
- loader->corrupted = TRUE;
- goto failed;
- }
-
- next_arg = header_len;
- while (next_arg < (header_len + body_len))
- {
- int type;
- int prev = next_arg;
-
- if (!_dbus_marshal_validate_type (&loader->data, next_arg,
- &type, &next_arg))
- {
- _dbus_verbose ("invalid typecode at offset %d\n", prev);
- loader->corrupted = TRUE;
- goto failed;
- }
-
- if (!_dbus_marshal_validate_arg (&loader->data,
- byte_order,
- 0,
- type, -1,
- next_arg,
- &next_arg))
- {
- _dbus_verbose ("invalid type data at %d, next_arg\n", next_arg);
- loader->corrupted = TRUE;
- goto failed;
- }
-
- _dbus_assert (next_arg > prev);
- }
-
- if (next_arg > (header_len + body_len))
- {
- _dbus_verbose ("end of last arg at %d but message has len %d+%d=%d\n",
- next_arg, header_len, body_len,
- header_len + body_len);
- loader->corrupted = TRUE;
- goto failed;
- }
-
- message = dbus_message_new_empty_header ();
- if (message == NULL)
- {
- _dbus_verbose ("Failed to allocate empty message\n");
- oom = TRUE;
- goto failed;
- }
-
- message->byte_order = byte_order;
- message->header_padding = header_padding;
-
- /* Copy in the offsets we found */
- i = 0;
- while (i <= DBUS_HEADER_FIELD_LAST)
- {
- message->header_fields[i] = fields[i];
- ++i;
- }
-
- if (!_dbus_list_append (&loader->messages, message))
- {
- _dbus_verbose ("Failed to append new message to loader queue\n");
- oom = TRUE;
- goto failed;
- }
-
- _dbus_assert (_dbus_string_get_length (&message->header) == 0);
- _dbus_assert (_dbus_string_get_length (&message->body) == 0);
-
- _dbus_assert (_dbus_string_get_length (&loader->data) >=
- (header_len + body_len));
-
- if (!_dbus_string_move_len (&loader->data, 0, header_len, &message->header, 0))
- {
- _dbus_verbose ("Failed to move header into new message\n");
- oom = TRUE;
- goto failed;
- }
-
- if (!_dbus_string_move_len (&loader->data, 0, body_len, &message->body, 0))
- {
- _dbus_verbose ("Failed to move body into new message\n");
-
- oom = TRUE;
- goto failed;
- }
-
- _dbus_assert (_dbus_string_get_length (&message->header) == header_len);
- _dbus_assert (_dbus_string_get_length (&message->body) == body_len);
-
- /* Fill in caches (we checked the types of these fields
- * earlier)
- */
- message->reply_serial = get_uint_field (message,
- DBUS_HEADER_FIELD_REPLY_SERIAL);
-
- message->client_serial = _dbus_demarshal_uint32 (&message->header,
- message->byte_order,
- CLIENT_SERIAL_OFFSET,
- NULL);
- if (message->client_serial == 0 ||
- (message->header_fields[DBUS_HEADER_FIELD_REPLY_SERIAL].value_offset >= 0 && message->reply_serial == 0))
- {
- _dbus_verbose ("client_serial = %d reply_serial = %d, one of these no good\n",
- message->client_serial,
- message->reply_serial);
-
- loader->corrupted = TRUE;
- goto failed;
- }
-
- /* 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");
- oom = TRUE;
- goto failed;
- }
-
- 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");
-
- oom = TRUE;
- goto failed;
- }
- }
- }
- }
- while (dbus_message_iter_next (&iter));
- }
-
- _dbus_verbose ("Loaded message %p\n", message);
-
- _dbus_assert (!oom);
- _dbus_assert (!loader->corrupted);
-
- return TRUE;
-
- failed:
-
- /* Clean up */
-
- if (message != NULL)
- {
- /* Put the data back so we can try again later if it was an OOM issue */
- if (_dbus_string_get_length (&message->body) > 0)
- {
- dbus_bool_t result;
-
- result = _dbus_string_copy_len (&message->body, 0, body_len,
- &loader->data, 0);
-
- _dbus_assert (result); /* because DBusString never reallocs smaller */
- }
-
- if (_dbus_string_get_length (&message->header) > 0)
- {
- dbus_bool_t result;
-
- result = _dbus_string_copy_len (&message->header, 0, header_len,
- &loader->data, 0);
-
- _dbus_assert (result); /* because DBusString never reallocs smaller */
- }
-
- /* does nothing if the message isn't in the list */
- _dbus_list_remove_last (&loader->messages, message);
-
- dbus_message_unref (message);
- }
-
-
- return !oom;
-}
-
-/**
- * Converts buffered data into messages.
- *
- * @todo we need to check that the proper named header fields exist
- * for each message type.
- *
- * @todo If a message has unknown type, we should probably eat it
- * right here rather than passing it out to applications. However
- * it's not an error to see messages of unknown type.
- *
- * @param loader the loader.
- * @returns #TRUE if we had enough memory to finish.
- */
-dbus_bool_t
-_dbus_message_loader_queue_messages (DBusMessageLoader *loader)
-{
- while (!loader->corrupted && _dbus_string_get_length (&loader->data) >= 16)
- {
- const char *header_data;
- int byte_order, message_type, header_len, body_len;
- dbus_uint32_t header_len_unsigned, body_len_unsigned;
-
- header_data = _dbus_string_get_const_data_len (&loader->data, 0, 16);
-
- _dbus_assert (_DBUS_ALIGN_ADDRESS (header_data, 4) == header_data);
-
- if (header_data[VERSION_OFFSET] != DBUS_MAJOR_PROTOCOL_VERSION)
- {
- _dbus_verbose ("Message has protocol version %d ours is %d\n",
- (int) header_data[VERSION_OFFSET], DBUS_MAJOR_PROTOCOL_VERSION);
- loader->corrupted = TRUE;
- return TRUE;
- }
-
- byte_order = header_data[BYTE_ORDER_OFFSET];
-
- if (byte_order != DBUS_LITTLE_ENDIAN &&
- byte_order != DBUS_BIG_ENDIAN)
- {
- _dbus_verbose ("Message with bad byte order '%c' received\n",
- byte_order);
- loader->corrupted = TRUE;
- return TRUE;
- }
-
- /* Unknown types are ignored, but INVALID is
- * disallowed
- */
- message_type = header_data[TYPE_OFFSET];
- if (message_type == DBUS_MESSAGE_TYPE_INVALID)
- {
- _dbus_verbose ("Message with bad type '%d' received\n",
- message_type);
- loader->corrupted = TRUE;
- return TRUE;
- }
-
- header_len_unsigned = _dbus_unpack_uint32 (byte_order, header_data + 4);
- body_len_unsigned = _dbus_unpack_uint32 (byte_order, header_data + 8);
-
- if (header_len_unsigned < 16)
- {
- _dbus_verbose ("Message had broken too-small header length %u\n",
- header_len_unsigned);
- loader->corrupted = TRUE;
- return TRUE;
- }
-
- if (header_len_unsigned > (unsigned) MAX_SANE_MESSAGE_SIZE ||
- body_len_unsigned > (unsigned) MAX_SANE_MESSAGE_SIZE)
- {
- _dbus_verbose ("Header or body length too large (%u %u)\n",
- header_len_unsigned,
- body_len_unsigned);
- loader->corrupted = TRUE;
- return TRUE;
- }
-
- /* Now that we know the values are in signed range, get
- * rid of stupid unsigned, just causes bugs
- */
- header_len = header_len_unsigned;
- body_len = body_len_unsigned;
-
- if (_DBUS_ALIGN_VALUE (header_len, 8) != header_len_unsigned)
- {
-
- _dbus_verbose ("header length %d is not aligned to 8 bytes\n",
- header_len);
- loader->corrupted = TRUE;
- return TRUE;
- }
-
- if (header_len + body_len > loader->max_message_size)
- {
- _dbus_verbose ("Message claimed length header = %d body = %d exceeds max message length %ld\n",
- header_len, body_len, loader->max_message_size);
- loader->corrupted = TRUE;
- return TRUE;
- }
-
- if (_dbus_string_get_length (&loader->data) >= (header_len + body_len))
- {
- if (!load_one_message (loader, byte_order, message_type,
- header_len, body_len))
- return FALSE;
- }
- else
- return TRUE;
- }
-
- return TRUE;
-}
-
-/**
- * Peeks at first loaded message, returns #NULL if no messages have
- * been queued.
- *
- * @param loader the loader.
- * @returns the next message, or #NULL if none.
- */
-DBusMessage*
-_dbus_message_loader_peek_message (DBusMessageLoader *loader)
-{
- if (loader->messages)
- return loader->messages->data;
- else
- return NULL;
-}
-
-/**
- * Pops a loaded message (passing ownership of the message
- * to the caller). Returns #NULL if no messages have been
- * queued.
- *
- * @param loader the loader.
- * @returns the next message, or #NULL if none.
- */
-DBusMessage*
-_dbus_message_loader_pop_message (DBusMessageLoader *loader)
-{
- return _dbus_list_pop_first (&loader->messages);
-}
-
-/**
- * Pops a loaded message inside a list link (passing ownership of the
- * message and link to the caller). Returns #NULL if no messages have
- * been loaded.
- *
- * @param loader the loader.
- * @returns the next message link, or #NULL if none.
- */
-DBusList*
-_dbus_message_loader_pop_message_link (DBusMessageLoader *loader)
-{
- return _dbus_list_pop_first_link (&loader->messages);
-}
-
-/**
- * Returns a popped message link, used to undo a pop.
- *
- * @param loader the loader
- * @param link the link with a message in it
- */
-void
-_dbus_message_loader_putback_message_link (DBusMessageLoader *loader,
- DBusList *link)
-{
- _dbus_list_prepend_link (&loader->messages, link);
-}
-
-/**
- * Checks whether the loader is confused due to bad data.
- * If messages are received that are invalid, the
- * loader gets confused and gives up permanently.
- * This state is called "corrupted."
- *
- * @param loader the loader
- * @returns #TRUE if the loader is hosed.
- */
-dbus_bool_t
-_dbus_message_loader_get_is_corrupted (DBusMessageLoader *loader)
-{
- return loader->corrupted;
-}
-
-/**
- * Sets the maximum size message we allow.
- *
- * @param loader the loader
- * @param size the max message size in bytes
- */
-void
-_dbus_message_loader_set_max_message_size (DBusMessageLoader *loader,
- long size)
-{
- if (size > MAX_SANE_MESSAGE_SIZE)
- {
- _dbus_verbose ("clamping requested max message size %ld to %d\n",
- size, MAX_SANE_MESSAGE_SIZE);
- size = MAX_SANE_MESSAGE_SIZE;
- }
- loader->max_message_size = size;
-}
-
-/**
- * Gets the maximum allowed message size in bytes.
- *
- * @param loader the loader
- * @returns max size in bytes
- */
-long
-_dbus_message_loader_get_max_message_size (DBusMessageLoader *loader)
-{
- return loader->max_message_size;
-}
-
-static DBusDataSlotAllocator slot_allocator;
-_DBUS_DEFINE_GLOBAL_LOCK (message_slots);
-
-/**
- * Allocates an integer ID to be used for storing application-specific
- * data on any DBusMessage. The allocated ID may then be used
- * with dbus_message_set_data() and dbus_message_get_data().
- * The passed-in slot must be initialized to -1, and is filled in
- * with the slot ID. If the passed-in slot is not -1, it's assumed
- * to be already allocated, and its refcount is incremented.
- *
- * The allocated slot is global, i.e. all DBusMessage objects will
- * have a slot with the given integer ID reserved.
- *
- * @param slot_p address of a global variable storing the slot
- * @returns #FALSE on failure (no memory)
- */
-dbus_bool_t
-dbus_message_allocate_data_slot (dbus_int32_t *slot_p)
-{
- return _dbus_data_slot_allocator_alloc (&slot_allocator,
- _DBUS_LOCK_NAME (message_slots),
- slot_p);
-}
-
-/**
- * Deallocates a global ID for message data slots.
- * dbus_message_get_data() and dbus_message_set_data() may no
- * longer be used with this slot. Existing data stored on existing
- * DBusMessage objects will be freed when the message is
- * finalized, but may not be retrieved (and may only be replaced if
- * someone else reallocates the slot). When the refcount on the
- * passed-in slot reaches 0, it is set to -1.
- *
- * @param slot_p address storing the slot to deallocate
- */
-void
-dbus_message_free_data_slot (dbus_int32_t *slot_p)
-{
- _dbus_return_if_fail (*slot_p >= 0);
-
- _dbus_data_slot_allocator_free (&slot_allocator, slot_p);
-}
-
-/**
- * Stores a pointer on a DBusMessage, along
- * with an optional function to be used for freeing
- * the data when the data is set again, or when
- * the message is finalized. The slot number
- * must have been allocated with dbus_message_allocate_data_slot().
- *
- * @param message the message
- * @param slot the slot number
- * @param data the data to store
- * @param free_data_func finalizer function for the data
- * @returns #TRUE if there was enough memory to store the data
- */
-dbus_bool_t
-dbus_message_set_data (DBusMessage *message,
- dbus_int32_t slot,
- void *data,
- DBusFreeFunction free_data_func)
-{
- DBusFreeFunction old_free_func;
- void *old_data;
- dbus_bool_t retval;
-
- _dbus_return_val_if_fail (message != NULL, FALSE);
- _dbus_return_val_if_fail (slot >= 0, FALSE);
-
- retval = _dbus_data_slot_list_set (&slot_allocator,
- &message->slot_list,
- slot, data, free_data_func,
- &old_free_func, &old_data);
-
- if (retval)
- {
- /* Do the actual free outside the message lock */
- if (old_free_func)
- (* old_free_func) (old_data);
- }
-
- return retval;
-}
-
-/**
- * Retrieves data previously set with dbus_message_set_data().
- * The slot must still be allocated (must not have been freed).
- *
- * @param message the message
- * @param slot the slot to get data from
- * @returns the data, or #NULL if not found
- */
-void*
-dbus_message_get_data (DBusMessage *message,
- dbus_int32_t slot)
-{
- void *res;
-
- _dbus_return_val_if_fail (message != NULL, NULL);
-
- res = _dbus_data_slot_list_get (&slot_allocator,
- &message->slot_list,
- slot);
-
- return res;
-}
-
-/**
- * Utility function to convert a machine-readable (not translated)
- * string into a D-BUS message type.
- *
- * @code
- * "method_call" -> DBUS_MESSAGE_TYPE_METHOD_CALL
- * "method_return" -> DBUS_MESSAGE_TYPE_METHOD_RETURN
- * "signal" -> DBUS_MESSAGE_TYPE_SIGNAL
- * "error" -> DBUS_MESSAGE_TYPE_ERROR
- * anything else -> DBUS_MESSAGE_TYPE_INVALID
- * @endcode
- *
- */
-int
-dbus_message_type_from_string (const char *type_str)
-{
- if (strcmp (type_str, "method_call") == 0)
- return DBUS_MESSAGE_TYPE_METHOD_CALL;
- if (strcmp (type_str, "method_return") == 0)
- return DBUS_MESSAGE_TYPE_METHOD_RETURN;
- else if (strcmp (type_str, "signal") == 0)
- return DBUS_MESSAGE_TYPE_SIGNAL;
- else if (strcmp (type_str, "error") == 0)
- return DBUS_MESSAGE_TYPE_ERROR;
- else
- return DBUS_MESSAGE_TYPE_INVALID;
-}
-
-/** @} */
-#ifdef DBUS_BUILD_TESTS
-#include "dbus-test.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-static void
-message_iter_test (DBusMessage *message)
-{
- DBusMessageIter iter, dict, dict2, array, array2;
- char *str;
- unsigned char *data;
- dbus_int32_t *our_int_array;
- int len;
-
- dbus_message_iter_init (message, &iter);
-
- /* String tests */
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING)
- _dbus_assert_not_reached ("Argument type isn't string");
-
- str = dbus_message_iter_get_string (&iter);
- if (strcmp (str, "Test string") != 0)
- _dbus_assert_not_reached ("Strings differ");
- dbus_free (str);
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- /* Signed integer tests */
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INT32)
- _dbus_assert_not_reached ("Argument type isn't int32");
-
- if (dbus_message_iter_get_int32 (&iter) != -0x12345678)
- _dbus_assert_not_reached ("Signed integers differ");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of fields");
-
- /* Unsigned integer tests */
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_UINT32)
- _dbus_assert_not_reached ("Argument type isn't int32");
-
- if (dbus_message_iter_get_uint32 (&iter) != 0xedd1e)
- _dbus_assert_not_reached ("Unsigned integers differ");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- /* Double tests */
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_DOUBLE)
- _dbus_assert_not_reached ("Argument type isn't double");
-
- if (dbus_message_iter_get_double (&iter) != 3.14159)
- _dbus_assert_not_reached ("Doubles differ");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY)
- _dbus_assert_not_reached ("Argument type not an array");
-
- if (dbus_message_iter_get_array_type (&iter) != DBUS_TYPE_DOUBLE)
- _dbus_assert_not_reached ("Array type not double");
-
-
- 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");
-
- if (dbus_message_iter_get_double (&array) != 1.5)
- _dbus_assert_not_reached ("Unsigned integers differ");
-
- if (!dbus_message_iter_next (&array))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_arg_type (&array) != DBUS_TYPE_DOUBLE)
- _dbus_assert_not_reached ("Argument type isn't double");
-
- if (dbus_message_iter_get_double (&array) != 2.5)
- _dbus_assert_not_reached ("Unsigned integers differ");
-
- if (dbus_message_iter_next (&array))
- _dbus_assert_not_reached ("Didn't reach end of arguments");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
-
- /* dict */
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_DICT)
- _dbus_assert_not_reached ("not dict type");
-
- dbus_message_iter_init_dict_iterator (&iter, &dict);
-
- str = dbus_message_iter_get_dict_key (&dict);
- if (str == NULL || strcmp (str, "test") != 0)
- _dbus_assert_not_reached ("wrong dict key");
- dbus_free (str);
-
- if (dbus_message_iter_get_arg_type (&dict) != DBUS_TYPE_UINT32)
- _dbus_assert_not_reached ("wrong dict entry type");
-
- if (dbus_message_iter_get_uint32 (&dict) != 0xDEADBEEF)
- _dbus_assert_not_reached ("wrong dict entry value");
-
- /* dict (in dict) */
-
- if (!dbus_message_iter_next (&dict))
- _dbus_assert_not_reached ("reached end of dict");
-
- if (dbus_message_iter_get_arg_type (&dict) != DBUS_TYPE_DICT)
- _dbus_assert_not_reached ("not dict type");
-
- dbus_message_iter_init_dict_iterator (&dict, &dict2);
-
- str = dbus_message_iter_get_dict_key (&dict2);
- if (str == NULL || strcmp (str, "dictkey") != 0)
- _dbus_assert_not_reached ("wrong dict key");
- dbus_free (str);
-
- if (dbus_message_iter_get_arg_type (&dict2) != DBUS_TYPE_STRING)
- _dbus_assert_not_reached ("wrong dict entry type");
-
- str = dbus_message_iter_get_string (&dict2);
- if (str == NULL || strcmp (str, "dictvalue") != 0)
- _dbus_assert_not_reached ("wrong dict entry value");
- dbus_free (str);
-
- if (dbus_message_iter_next (&dict2))
- _dbus_assert_not_reached ("didn't reach end of dict");
-
- if (!dbus_message_iter_next (&dict))
- _dbus_assert_not_reached ("reached end of dict");
-
- /* array of array of int32 (in dict) */
-
- str = dbus_message_iter_get_dict_key (&dict);
- if (str == NULL || strcmp (str, "array") != 0)
- _dbus_assert_not_reached ("wrong dict key");
- dbus_free (str);
-
- if (dbus_message_iter_get_arg_type (&dict) != DBUS_TYPE_ARRAY)
- _dbus_assert_not_reached ("Argument type not an array");
-
- if (dbus_message_iter_get_array_type (&dict) != DBUS_TYPE_ARRAY)
- _dbus_assert_not_reached ("Array type not array");
-
- 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");
-
- if (dbus_message_iter_get_array_type (&array) != DBUS_TYPE_INT32)
- _dbus_assert_not_reached ("Array type not int32");
-
- 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");
-
- if (dbus_message_iter_get_int32 (&array2) != 0x12345678)
- _dbus_assert_not_reached ("Signed integers differ");
-
- if (!dbus_message_iter_next (&array2))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_int32 (&array2) != 0x23456781)
- _dbus_assert_not_reached ("Signed integers differ");
-
- if (dbus_message_iter_next (&array2))
- _dbus_assert_not_reached ("Didn't reached end of arguments");
-
- if (!dbus_message_iter_next (&array))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_array_type (&array) != DBUS_TYPE_INT32)
- _dbus_assert_not_reached ("Array type not int32");
-
- if (!dbus_message_iter_get_int32_array (&array,
- &our_int_array,
- &len))
- _dbus_assert_not_reached ("couldn't get int32 array");
-
- _dbus_assert (len == 3);
- _dbus_assert (our_int_array[0] == 0x34567812 &&
- our_int_array[1] == 0x45678123 &&
- our_int_array[2] == 0x56781234);
- dbus_free (our_int_array);
-
- if (dbus_message_iter_next (&array))
- _dbus_assert_not_reached ("Didn't reach end of array");
-
- if (dbus_message_iter_next (&dict))
- _dbus_assert_not_reached ("Didn't reach end of dict");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_BYTE)
- {
- _dbus_warn ("type was: %d\n", dbus_message_iter_get_arg_type (&iter));
- _dbus_assert_not_reached ("wrong type after dict (should be byte)");
- }
-
- if (dbus_message_iter_get_byte (&iter) != 0xF0)
- _dbus_assert_not_reached ("wrong value after dict");
-
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_NIL)
- _dbus_assert_not_reached ("not a nil type");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_CUSTOM)
- _dbus_assert_not_reached ("wrong type after dict");
-
- if (!dbus_message_iter_get_custom (&iter, &str, &data, &len))
- _dbus_assert_not_reached ("failed to get custom type");
-
- _dbus_assert (strcmp (str, "MyTypeName")==0);
- _dbus_assert (len == 5);
- _dbus_assert (strcmp (data, "data")==0);
- dbus_free (str);
- dbus_free (data);
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_byte (&iter) != 0xF0)
- _dbus_assert_not_reached ("wrong value after custom");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY)
- _dbus_assert_not_reached ("no array");
-
- if (dbus_message_iter_get_array_type (&iter) != DBUS_TYPE_INT32)
- _dbus_assert_not_reached ("Array type not int32");
-
- if (dbus_message_iter_init_array_iterator (&iter, &array, NULL))
- _dbus_assert_not_reached ("non empty array");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_byte (&iter) != 0xF0)
- _dbus_assert_not_reached ("wrong value after empty array");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_DICT)
- _dbus_assert_not_reached ("non dict");
-
- if (dbus_message_iter_init_dict_iterator (&iter, &dict))
- _dbus_assert_not_reached ("non empty dict");
-
- if (!dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Reached end of arguments");
-
- if (dbus_message_iter_get_byte (&iter) != 0xF0)
- _dbus_assert_not_reached ("wrong value after empty dict");
-
- if (dbus_message_iter_next (&iter))
- _dbus_assert_not_reached ("Didn't reach end of arguments");
-}
-
-
-static dbus_bool_t
-check_message_handling_type (DBusMessageIter *iter,
- int type)
-{
- DBusMessageIter child_iter;
-
- switch (type)
- {
- case DBUS_TYPE_NIL:
- break;
- case DBUS_TYPE_BYTE:
- dbus_message_iter_get_byte (iter);
- break;
- case DBUS_TYPE_BOOLEAN:
- dbus_message_iter_get_boolean (iter);
- break;
- case DBUS_TYPE_INT32:
- dbus_message_iter_get_int32 (iter);
- break;
- case DBUS_TYPE_UINT32:
- dbus_message_iter_get_uint32 (iter);
- break;
- case DBUS_TYPE_INT64:
-#ifdef DBUS_HAVE_INT64
- dbus_message_iter_get_int64 (iter);
-#endif
- break;
- case DBUS_TYPE_UINT64:
-#ifdef DBUS_HAVE_INT64
- dbus_message_iter_get_uint64 (iter);
-#endif
- break;
- case DBUS_TYPE_DOUBLE:
- dbus_message_iter_get_double (iter);
- break;
- case DBUS_TYPE_STRING:
- {
- char *str;
- str = dbus_message_iter_get_string (iter);
- if (str == NULL)
- {
- _dbus_warn ("NULL string in message\n");
- return FALSE;
- }
- dbus_free (str);
- }
- break;
- case DBUS_TYPE_CUSTOM:
- {
- char *name;
- unsigned char *data;
- int len;
-
- if (!dbus_message_iter_get_custom (iter, &name, &data, &len))
- {
- _dbus_warn ("error reading name from custom type\n");
- return FALSE;
- }
- dbus_free (data);
- dbus_free (name);
- }
- break;
- case DBUS_TYPE_ARRAY:
- {
- int array_type;
-
- dbus_message_iter_init_array_iterator (iter, &child_iter, &array_type);
-
- while (dbus_message_iter_has_next (&child_iter))
- {
- if (!check_message_handling_type (&child_iter, array_type))
- {
- _dbus_warn ("error in array element\n");
- return FALSE;
- }
-
- if (!dbus_message_iter_next (&child_iter))
- break;
- }
- }
- break;
- case DBUS_TYPE_DICT:
- {
- int entry_type;
- char *key;
-
- dbus_message_iter_init_dict_iterator (iter, &child_iter);
-
- while ((entry_type = dbus_message_iter_get_arg_type (&child_iter)) != DBUS_TYPE_INVALID)
- {
- key = dbus_message_iter_get_dict_key (&child_iter);
- if (key == NULL)
- {
- _dbus_warn ("error reading dict key\n");
- return FALSE;
- }
- dbus_free (key);
-
- if (!check_message_handling_type (&child_iter, entry_type))
- {
- _dbus_warn ("error in dict value\n");
- return FALSE;
- }
-
- if (!dbus_message_iter_next (&child_iter))
- break;
- }
- }
- break;
-
- default:
- _dbus_warn ("unknown type %d\n", type);
- return FALSE;
- break;
- }
- return TRUE;
-}
-
-
-static dbus_bool_t
-check_message_handling (DBusMessage *message)
-{
- DBusMessageIter iter;
- int type;
- dbus_bool_t retval;
- dbus_uint32_t client_serial;
-
- retval = FALSE;
-
- client_serial = dbus_message_get_serial (message);
-
- /* can't use set_serial due to the assertions at the start of it */
- _dbus_marshal_set_uint32 (&message->header,
- message->byte_order,
- CLIENT_SERIAL_OFFSET,
- client_serial);
-
- if (client_serial != dbus_message_get_serial (message))
- {
- _dbus_warn ("get/set cycle for client_serial did not succeed\n");
- goto failed;
- }
-
- /* If we implement message_set_arg (message, n, value)
- * then we would want to test it here
- */
-
- dbus_message_iter_init (message, &iter);
- while ((type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID)
- {
- if (!check_message_handling_type (&iter, type))
- goto failed;
-
- if (!dbus_message_iter_next (&iter))
- break;
- }
-
- retval = TRUE;
-
- failed:
- return retval;
-}
-
-static dbus_bool_t
-check_have_valid_message (DBusMessageLoader *loader)
-{
- DBusMessage *message;
- dbus_bool_t retval;
-
- message = NULL;
- retval = FALSE;
-
- if (!_dbus_message_loader_queue_messages (loader))
- _dbus_assert_not_reached ("no memory to queue messages");
-
- if (_dbus_message_loader_get_is_corrupted (loader))
- {
- _dbus_warn ("loader corrupted on message that was expected to be valid\n");
- goto failed;
- }
-
- message = _dbus_message_loader_pop_message (loader);
- if (message == NULL)
- {
- _dbus_warn ("didn't load message that was expected to be valid (message not popped)\n");
- goto failed;
- }
-
- if (_dbus_string_get_length (&loader->data) > 0)
- {
- _dbus_warn ("had leftover bytes from expected-to-be-valid single message\n");
- goto failed;
- }
-
- /* Verify that we're able to properly deal with the message.
- * For example, this would detect improper handling of messages
- * in nonstandard byte order.
- */
- if (!check_message_handling (message))
- goto failed;
-
- retval = TRUE;
-
- failed:
- if (message)
- dbus_message_unref (message);
-
- return retval;
-}
-
-static dbus_bool_t
-check_invalid_message (DBusMessageLoader *loader)
-{
- dbus_bool_t retval;