From 1f8390c0027ea217a906d94e18837a486c98d680 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 23 Nov 2021 12:57:29 +0000 Subject: [PATCH] gdbusmessage: Remove arbitrary restriction on minimum D-Bus blob length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code in `g_dbus_message_new_from_blob()` has now been fixed to correctly error out on all truncated messages, so there’s no need for an arbitrary programmer error if the input is too short to contain a valid D-Bus message header. Signed-off-by: Philip Withnall Helps: #2528 --- gio/gdbusmessage.c | 1 - gio/tests/gdbus-serialization.c | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c index cbd9e087c..0b803bc30 100644 --- a/gio/gdbusmessage.c +++ b/gio/gdbusmessage.c @@ -2168,7 +2168,6 @@ g_dbus_message_new_from_blob (guchar *blob, g_return_val_if_fail (blob != NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); - g_return_val_if_fail (blob_len >= 12, NULL); message = g_dbus_message_new (); diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c index df1c63ca2..4f0634cf1 100644 --- a/gio/tests/gdbus-serialization.c +++ b/gio/tests/gdbus-serialization.c @@ -1512,10 +1512,8 @@ test_message_parse_truncated (void) g_clear_object (&message); - /* 12 bytes is the minimum size of the D-Bus message header. Anything less - * than that is rejected as a programming error by - * g_dbus_message_new_from_blob(). */ - for (gsize i = 12; i < size; i++) + /* Try parsing all possible prefixes of the full @blob. */ + for (gsize i = 0; i < size; i++) { message2 = g_dbus_message_new_from_blob (blob, i, G_DBUS_CAPABILITY_FLAGS_NONE, &error); g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);