mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-31 21:34:12 +02:00
gdbusmessage: Validate type of message header signature field
Parsing a D-Bus message with the signature field in the message header of type other than ‘g’ (GVariant type signature) would cause a critical warning. Instead, we should return a runtime error. Includes a test. oss-fuzz#9825 Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
@@ -2115,6 +2115,15 @@ g_dbus_message_new_from_blob (guchar *blob,
|
||||
const gchar *signature_str;
|
||||
gsize signature_str_len;
|
||||
|
||||
if (!g_variant_is_of_type (signature, G_VARIANT_TYPE_SIGNATURE))
|
||||
{
|
||||
g_set_error_literal (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_INVALID_ARGUMENT,
|
||||
_("Signature header found but is not of type signature"));
|
||||
goto out;
|
||||
}
|
||||
|
||||
signature_str = g_variant_get_string (signature, &signature_str_len);
|
||||
|
||||
/* signature but no body */
|
||||
@@ -2695,6 +2704,16 @@ g_dbus_message_to_blob (GDBusMessage *message,
|
||||
body_start_offset = mbuf.valid_len;
|
||||
|
||||
signature = g_dbus_message_get_header (message, G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE);
|
||||
|
||||
if (signature != NULL && !g_variant_is_of_type (signature, G_VARIANT_TYPE_SIGNATURE))
|
||||
{
|
||||
g_set_error_literal (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_INVALID_ARGUMENT,
|
||||
_("Signature header found but is not of type signature"));
|
||||
goto out;
|
||||
}
|
||||
|
||||
signature_str = NULL;
|
||||
if (signature != NULL)
|
||||
signature_str = g_variant_get_string (signature, NULL);
|
||||
|
Reference in New Issue
Block a user