mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 15:33:39 +02:00
gdbusmessage: Disallow empty structures/tuples in D-Bus messages
They are disallowed in the specification: https://dbus.freedesktop.org/doc/dbus-specification.html#container-types Helps: #2557
This commit is contained in:
committed by
Philip Withnall
parent
77233f6f07
commit
6499ad5356
@@ -1907,6 +1907,16 @@ parse_value_from_blob (GMemoryBuffer *buf,
|
||||
|
||||
g_variant_builder_init (&builder, type);
|
||||
element_type = g_variant_type_first (type);
|
||||
if (!element_type)
|
||||
{
|
||||
g_variant_builder_clear (&builder);
|
||||
g_set_error_literal (&local_error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_INVALID_ARGUMENT,
|
||||
_("Empty structures (tuples) are not allowed in D-Bus"));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
while (element_type != NULL)
|
||||
{
|
||||
GVariant *item;
|
||||
@@ -2617,6 +2627,15 @@ append_value_to_blob (GVariant *value,
|
||||
default:
|
||||
if (g_variant_type_is_dict_entry (type) || g_variant_type_is_tuple (type))
|
||||
{
|
||||
if (!g_variant_type_first (type))
|
||||
{
|
||||
g_set_error_literal (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_INVALID_ARGUMENT,
|
||||
_("Empty structures (tuples) are not allowed in D-Bus"));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
padding_added = ensure_output_padding (mbuf, 8);
|
||||
if (value != NULL)
|
||||
{
|
||||
|
Reference in New Issue
Block a user