diff options
author | Havoc Pennington <hp@redhat.com> | 2004-05-28 22:30:04 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2004-05-28 22:30:04 +0000 |
commit | fbae5baa06819fed71f62ddbba64a64675c2d333 (patch) | |
tree | d945583c65f22233b61fc0e912525d5cd8b3ff8f /dbus | |
parent | 1041b44d304cca543fe133b338b2021bbeffa913 (diff) |
2004-05-28 Havoc Pennington <hp@redhat.com>
* test/glib/test-service-glib.c (main): remove unused variable
* glib/dbus-gidl.c (base_info_ref): fix a silly compiler warning
* dbus/dbus-auth.h (enum): remove AUTHENTICATED_WITH_UNUSED_BYTES
from the enum, no longer in use.
* dbus/dbus-sysdeps.h: include config.h so DBUS_VA_COPY actually
works right.
* dbus/dbus-message.c: add various _dbus_return_val_if_fail for
whether error_name passed in is a valid error name.
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-auth.h | 1 | ||||
-rw-r--r-- | dbus/dbus-message.c | 41 | ||||
-rw-r--r-- | dbus/dbus-sysdeps.h | 2 |
3 files changed, 40 insertions, 4 deletions
diff --git a/dbus/dbus-auth.h b/dbus/dbus-auth.h index 5678a8c9..aa20ed52 100644 --- a/dbus/dbus-auth.h +++ b/dbus/dbus-auth.h @@ -38,7 +38,6 @@ typedef enum DBUS_AUTH_STATE_WAITING_FOR_MEMORY, DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND, DBUS_AUTH_STATE_NEED_DISCONNECT, - DBUS_AUTH_STATE_AUTHENTICATED_WITH_UNUSED_BYTES, DBUS_AUTH_STATE_AUTHENTICATED } DBusAuthState; diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index feeebf0f..850af21c 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -171,6 +171,23 @@ clear_header_padding (DBusMessage *message) message->header_padding = 0; } +#ifdef DBUS_DISABLE_CHECKS +#define is_valid_error_name(x) TRUE +#else +static dbus_bool_t +is_valid_error_name (const char *error_name) +{ + DBusString the_error_name; + + if (error_name == NULL) + return FALSE; + + _dbus_string_init_const (&the_error_name, error_name); + return _dbus_string_validate_error_name (&the_error_name, 0, + _dbus_string_get_length (&the_error_name)); +} +#endif + static dbus_bool_t append_header_padding (DBusMessage *message) { @@ -1022,6 +1039,7 @@ dbus_message_create_header (DBusMessage *message, _dbus_assert ((interface && member) || (error_name) || !(interface || member || error_name)); + _dbus_assert (error_name == NULL || is_valid_error_name (error_name)); if (!_dbus_string_append_byte (&message->header, message->byte_order)) return FALSE; @@ -1378,6 +1396,7 @@ dbus_message_new_error (DBusMessage *reply_to, _dbus_return_val_if_fail (reply_to != NULL, NULL); _dbus_return_val_if_fail (error_name != NULL, NULL); + _dbus_return_val_if_fail (is_valid_error_name (error_name), NULL); sender = get_string_field (reply_to, DBUS_HEADER_FIELD_SENDER, @@ -1441,6 +1460,10 @@ dbus_message_new_error_printf (DBusMessage *reply_to, DBusString str; DBusMessage *message; + _dbus_return_val_if_fail (reply_to != NULL, NULL); + _dbus_return_val_if_fail (error_name != NULL, NULL); + _dbus_return_val_if_fail (is_valid_error_name (error_name), NULL); + if (!_dbus_string_init (&str)) return NULL; @@ -1787,7 +1810,9 @@ dbus_message_set_error_name (DBusMessage *message, { _dbus_return_val_if_fail (message != NULL, FALSE); _dbus_return_val_if_fail (!message->locked, FALSE); - + _dbus_return_val_if_fail (error_name != NULL, FALSE); + _dbus_return_val_if_fail (is_valid_error_name (error_name), FALSE); + return set_string_field (message, DBUS_HEADER_FIELD_ERROR_NAME, DBUS_TYPE_STRING, @@ -3819,6 +3844,9 @@ dbus_message_append_args_valist (DBusMessage *message, goto errorout; break; case DBUS_TYPE_BYTE: + /* FIXME if you pass an unsigned char to varargs it gets promoted to int, + * so probably we should read an int here. + */ if (!dbus_message_iter_append_byte (&iter, va_arg (var_args, unsigned char))) goto errorout; break; @@ -3827,10 +3855,16 @@ dbus_message_append_args_valist (DBusMessage *message, goto errorout; break; case DBUS_TYPE_INT32: + /* FIXME this is probably wrong, because an int passed in probably gets + * converted to plain "int" not necessarily 32-bit. + */ if (!dbus_message_iter_append_int32 (&iter, va_arg (var_args, dbus_int32_t))) goto errorout; break; case DBUS_TYPE_UINT32: + /* FIXME this is probably wrong, because an int passed in probably gets + * converted to plain "int" not necessarily 32-bit. + */ if (!dbus_message_iter_append_uint32 (&iter, va_arg (var_args, dbus_uint32_t))) goto errorout; break; @@ -4367,13 +4401,14 @@ dbus_message_is_signal (DBusMessage *message, */ dbus_bool_t dbus_message_is_error (DBusMessage *message, - const char *error_name) + const char *error_name) { const char *n; _dbus_return_val_if_fail (message != NULL, FALSE); _dbus_return_val_if_fail (error_name != NULL, FALSE); - + _dbus_return_val_if_fail (is_valid_error_name (error_name), FALSE); + if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR) return FALSE; diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 1d32d298..df4c8d6c 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -25,6 +25,8 @@ #ifndef DBUS_SYSDEPS_H #define DBUS_SYSDEPS_H +#include <config.h> + #include <dbus/dbus-errors.h> /* this is perhaps bogus, but strcmp() etc. are faster if we use the |