Blame 0118-dbus-validate-parameters-of-all-calls.patch

69165ba
From 7a47f57975be0d285a2f20758e4572dca6d9cdd3 Mon Sep 17 00:00:00 2001
69165ba
From: Jakub Filak <jfilak@redhat.com>
69165ba
Date: Wed, 13 May 2015 11:10:23 +0200
69165ba
Subject: [ABRT PATCH] dbus: validate parameters of all calls
69165ba
69165ba
SetElement and DeleteElement were missing check for valid dump directory
69165ba
path.
69165ba
69165ba
FindProblemByElementInTimeRange was not reporting invalid element names.
69165ba
69165ba
Related: #1214451
69165ba
69165ba
Signed-off-by: Jakub Filak <jfilak@redhat.com>
69165ba
---
69165ba
 src/dbus/abrt-dbus.c | 24 ++++++++++++++++++++++++
69165ba
 1 file changed, 24 insertions(+)
69165ba
69165ba
diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c
69165ba
index bef95bd..f2f742b 100644
69165ba
--- a/src/dbus/abrt-dbus.c
69165ba
+++ b/src/dbus/abrt-dbus.c
69165ba
@@ -607,6 +607,12 @@ static void handle_method_call(GDBusConnection *connection,
69165ba
 
69165ba
         g_variant_get(parameters, "(&s&s&s)", &problem_id, &element, &value);
69165ba
 
69165ba
+        if (!allowed_problem_dir(problem_id))
69165ba
+        {
69165ba
+            return_InvalidProblemDir_error(invocation, problem_id);
69165ba
+            return;
69165ba
+        }
69165ba
+
69165ba
         if (!str_is_correct_filename(element))
69165ba
         {
69165ba
             log_notice("'%s' is not a valid element name of '%s'", element, problem_id);
69165ba
@@ -666,6 +672,12 @@ static void handle_method_call(GDBusConnection *connection,
69165ba
 
69165ba
         g_variant_get(parameters, "(&s&s)", &problem_id, &element);
69165ba
 
69165ba
+        if (!allowed_problem_dir(problem_id))
69165ba
+        {
69165ba
+            return_InvalidProblemDir_error(invocation, problem_id);
69165ba
+            return;
69165ba
+        }
69165ba
+
69165ba
         if (!str_is_correct_filename(element))
69165ba
         {
69165ba
             log_notice("'%s' is not a valid element name of '%s'", element, problem_id);
69165ba
@@ -783,6 +795,18 @@ static void handle_method_call(GDBusConnection *connection,
69165ba
         g_variant_get_child(parameters, 3, "x", &timestamp_to);
69165ba
         g_variant_get_child(parameters, 4, "b", &all;;
69165ba
 
69165ba
+        if (!str_is_correct_filename(element))
69165ba
+        {
69165ba
+            log_notice("'%s' is not a valid element name", element);
69165ba
+            char *error = xasprintf(_("'%s' is not a valid element name"), element);
69165ba
+            g_dbus_method_invocation_return_dbus_error(invocation,
69165ba
+                                              "org.freedesktop.problems.InvalidElement",
69165ba
+                                              error);
69165ba
+
69165ba
+            free(error);
69165ba
+            return;
69165ba
+        }
69165ba
+
69165ba
         if (all && polkit_check_authorization_dname(caller, "org.freedesktop.problems.getall") == PolkitYes)
69165ba
             caller_uid = 0;
69165ba
 
69165ba
-- 
69165ba
1.8.3.1
69165ba