[glib] gdbus: Validate the --dest argument
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gdbus: Validate the --dest argument
- Date: Thu, 9 Apr 2015 21:27:31 +0000 (UTC)
commit 21107959ab12da217151fe8d5f0eb65bd93fd5aa
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Apr 8 22:07:26 2015 -0400
gdbus: Validate the --dest argument
Passing an nonsense string for the --dest argument can lead
to a segfault of gdbus. Thats not nice, so use our existing
validation function for bus names here.
https://bugzilla.gnome.org/show_bug.cgi?id=747541
gio/gdbus-tool.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c
index f24dd71..c021f48 100644
--- a/gio/gdbus-tool.c
+++ b/gio/gdbus-tool.c
@@ -203,6 +203,12 @@ print_paths (GDBusConnection *c,
GDBusNodeInfo *node;
guint n;
+ if (!g_dbus_is_name (name))
+ {
+ g_printerr (_("Error: %s is not a valid name\n"), name);
+ goto out;
+ }
+
error = NULL;
result = g_dbus_connection_call_sync (c,
name,
@@ -863,6 +869,12 @@ handle_call (gint *argc,
}
}
+ if (!request_completion && !g_dbus_is_name (opt_call_dest))
+ {
+ g_printerr (_("Error: %s is not a valid bus name\n"), opt_call_dest);
+ goto out;
+ }
+
/* validate and complete object path */
if (complete_paths)
{
@@ -1601,6 +1613,13 @@ handle_introspect (gint *argc,
print_paths (c, opt_introspect_dest, "/");
goto out;
}
+
+ if (!request_completion && !g_dbus_is_name (opt_introspect_dest))
+ {
+ g_printerr (_("Error: %s is not a valid bus name\n"), opt_introspect_dest);
+ goto out;
+ }
+
if (opt_introspect_object_path == NULL)
{
if (request_completion)
@@ -1824,6 +1843,13 @@ handle_monitor (gint *argc,
goto out;
}
}
+
+ if (!request_completion && !g_dbus_is_name (opt_monitor_dest))
+ {
+ g_printerr (_("Error: %s is not a valid bus name\n"), opt_monitor_dest);
+ goto out;
+ }
+
if (complete_paths)
{
print_paths (c, opt_monitor_dest, "/");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]