* @{
*/
+/**
+ * Gets the number of unix fds attached to this message.
+ *
+ * @param message the message
+ * @returns the number of file descriptors
+ */
+unsigned int
+_dbus_message_get_n_unix_fds (DBusMessage *message)
+{
+#ifdef HAVE_UNIX_FD_PASSING
+ return message->n_unix_fds;
+#else
+ return 0;
+#endif
+}
+
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
/**
* Reads arguments from a message iterator given a variable argument
if (_dbus_get_malloc_blocks_outstanding () != 0)
{
- _dbus_warn ("%d dbus_malloc blocks were not freed in %s\n",
+ _dbus_warn ("%d dbus_malloc blocks were not freed in %s",
_dbus_get_malloc_blocks_outstanding (), __FILE__);
_dbus_assert_not_reached ("memleaks");
}
if (fd == dirfd (d))
continue;
+ if (fd >= FD_SETSIZE)
+ {
+ _dbus_verbose ("FD %d unexpectedly large; cannot track whether "
+ "it is leaked\n", fd);
+ continue;
+ }
+
FD_SET (fd, &fds->set);
}
if (fd == dirfd (d))
continue;
+ if (fd >= FD_SETSIZE)
+ {
+ _dbus_verbose ("FD %d unexpectedly large; cannot track whether "
+ "it is leaked\n", fd);
+ continue;
+ }
+
if (FD_ISSET (fd, &fds->set))
continue;
- _dbus_warn ("file descriptor %i leaked in %s.\n", fd, __FILE__);
+ _dbus_warn ("file descriptor %i leaked in %s.", fd, __FILE__);
_dbus_assert_not_reached ("fdleaks");
}
if (_dbus_message_loader_get_is_corrupted (loader))
{
- _dbus_warn ("loader corrupted on message that was expected to be valid; invalid reason %d\n",
+ _dbus_warn ("loader corrupted on message that was expected to be valid; invalid reason %d",
loader->corruption_reason);
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");
+ _dbus_warn ("didn't load message that was expected to be valid (message not popped)");
goto failed;
}
if (_dbus_string_get_length (&loader->data) > 0)
{
- _dbus_warn ("had leftover bytes from expected-to-be-valid single message\n");
+ _dbus_warn ("had leftover bytes from expected-to-be-valid single message");
goto failed;
}
if (!_dbus_message_loader_get_is_corrupted (loader))
{
- _dbus_warn ("loader not corrupted on message that was expected to be invalid\n");
+ _dbus_warn ("loader not corrupted on message that was expected to be invalid");
goto failed;
}
if (expected_validity != DBUS_INVALID_FOR_UNKNOWN_REASON &&
loader->corruption_reason != expected_validity)
{
- _dbus_warn ("expected message to be corrupted for reason %d and was corrupted for %d instead\n",
+ _dbus_warn ("expected message to be corrupted for reason %d and was corrupted for %d instead",
expected_validity, loader->corruption_reason);
goto failed;
}
if (_dbus_message_loader_get_is_corrupted (loader))
{
- _dbus_warn ("loader corrupted on message that was expected to be valid (but incomplete), corruption reason %d\n",
+ _dbus_warn ("loader corrupted on message that was expected to be valid (but incomplete), corruption reason %d",
loader->corruption_reason);
goto failed;
}
message = _dbus_message_loader_pop_message (loader);
if (message != NULL)
{
- _dbus_warn ("loaded message that was expected to be incomplete\n");
+ _dbus_warn ("loaded message that was expected to be incomplete");
goto failed;
}
_dbus_verbose ("Loading raw %s\n", _dbus_string_get_const_data (filename));
if (!_dbus_file_get_contents (data, filename, &error))
{
- _dbus_warn ("Could not load message file %s: %s\n",
+ _dbus_warn ("Could not load message file %s: %s",
_dbus_string_get_const_data (filename),
error.message);
dbus_error_free (&error);
retval = FALSE;
if (!_dbus_string_init (&data))
- _dbus_assert_not_reached ("could not allocate string\n");
+ _dbus_assert_not_reached ("could not allocate string");
if (!dbus_internal_do_not_use_load_message_file (filename, &data))
goto failed;
_dbus_verbose_bytes_of_string (&data, 0,
_dbus_string_get_length (&data));
- _dbus_warn ("Failed message loader test on %s\n",
+ _dbus_warn ("Failed message loader test on %s",
_dbus_string_get_const_data (filename));
}
/* Write the data one byte at a time */
loader = _dbus_message_loader_new ();
+ if (loader == NULL)
+ goto failed;
/* check some trivial loader functions */
_dbus_message_loader_ref (loader);
{
DBusString *buffer;
- _dbus_message_loader_get_buffer (loader, &buffer);
- _dbus_string_append_byte (buffer,
- _dbus_string_get_byte (data, i));
+ _dbus_message_loader_get_buffer (loader, &buffer, NULL, NULL);
+ if (!_dbus_string_append_byte (buffer,
+ _dbus_string_get_byte (data, i)))
+ goto failed;
_dbus_message_loader_return_buffer (loader, buffer);
}
/* Write the data all at once */
loader = _dbus_message_loader_new ();
+ if (loader == NULL)
+ goto failed;
{
DBusString *buffer;
- _dbus_message_loader_get_buffer (loader, &buffer);
- _dbus_string_copy (data, 0, buffer,
- _dbus_string_get_length (buffer));
+ _dbus_message_loader_get_buffer (loader, &buffer, NULL, NULL);
+ if (!_dbus_string_copy (data, 0, buffer,
+ _dbus_string_get_length (buffer)))
+ goto failed;
_dbus_message_loader_return_buffer (loader, buffer);
}
/* Write the data 2 bytes at a time */
loader = _dbus_message_loader_new ();
+ if (loader == NULL)
+ goto failed;
len = _dbus_string_get_length (data);
for (i = 0; i < len; i += 2)
{
DBusString *buffer;
- _dbus_message_loader_get_buffer (loader, &buffer);
- _dbus_string_append_byte (buffer,
- _dbus_string_get_byte (data, i));
+ _dbus_message_loader_get_buffer (loader, &buffer, NULL, NULL);
+ if (!_dbus_string_append_byte (buffer,
+ _dbus_string_get_byte (data, i)))
+ goto failed;
+
if ((i+1) < len)
- _dbus_string_append_byte (buffer,
- _dbus_string_get_byte (data, i+1));
+ {
+ if (!_dbus_string_append_byte (buffer,
+ _dbus_string_get_byte (data, i+1)))
+ goto failed;
+ }
+
_dbus_message_loader_return_buffer (loader, buffer);
}
dir = _dbus_directory_open (&test_directory, &error);
if (dir == NULL)
{
- _dbus_warn ("Could not open %s: %s\n",
+ _dbus_warn ("Could not open %s: %s",
_dbus_string_get_const_data (&test_directory),
error.message);
dbus_error_free (&error);
if (dbus_error_is_set (&error))
{
- _dbus_warn ("Could not get next file in %s: %s\n",
+ _dbus_warn ("Could not get next file in %s: %s",
_dbus_string_get_const_data (&test_directory),
error.message);
dbus_error_free (&error);
&our_string_array, &our_string_array_len,
0))
{
- _dbus_warn ("error: %s - %s\n", error.name,
+ _dbus_warn ("error: %s - %s", error.name,
(error.message != NULL) ? error.message : "no message");
_dbus_assert_not_reached ("Could not get arguments");
}
if (!dbus_message_iter_get_args (&iter, &error,
DBUS_TYPE_INVALID))
{
- _dbus_warn ("error: %s - %s\n", error.name,
+ _dbus_warn ("error: %s - %s", error.name,
(error.message != NULL) ? error.message : "no message");
}
else
DBUS_TYPE_UINT32, &our_uint,
DBUS_TYPE_INVALID))
{
- _dbus_warn ("error: %s - %s\n", error.name,
+ _dbus_warn ("error: %s - %s", error.name,
(error.message != NULL) ? error.message : "no message");
}
else
}
else
{
- _dbus_warn ("error: parse with wrong signature: 'uashuu'.\n");
+ _dbus_warn ("error: parse with wrong signature: 'uashuu'.");
}
/* parse with wrong signature: "uashuashu" */
}
else
{
- _dbus_warn ("error: parse with wrong signature: 'uashuashu'.\n");
+ _dbus_warn ("error: parse with wrong signature: 'uashuashu'.");
}
/* parse with correct signature: "uashuash" */
#endif
DBUS_TYPE_INVALID))
{
- _dbus_warn ("error: %s - %s\n", error.name,
+ _dbus_warn ("error: %s - %s", error.name,
(error.message != NULL) ? error.message : "no message");
_dbus_assert_not_reached ("Could not get arguments");
}
{
DBusString *buffer;
- _dbus_message_loader_get_buffer (loader, &buffer);
+ _dbus_message_loader_get_buffer (loader, &buffer, NULL, NULL);
_dbus_string_append_byte (buffer, data[i]);
_dbus_message_loader_return_buffer (loader, buffer);
}
{
DBusString *buffer;
- _dbus_message_loader_get_buffer (loader, &buffer);
+ _dbus_message_loader_get_buffer (loader, &buffer, NULL, NULL);
_dbus_string_append_byte (buffer, data[i]);
_dbus_message_loader_return_buffer (loader, buffer);
}
if (!dbus_internal_do_not_use_try_message_data (&mdata.data,
mdata.expected_validity))
{
- _dbus_warn ("expected validity %d and did not get it\n",
+ _dbus_warn ("expected validity %d and did not get it",
mdata.expected_validity);
_dbus_assert_not_reached ("message data failed");
}