doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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