Blame SOURCES/0109-dbus-report-invalid-element-names.patch

06486d
From f3c2a6af3455b2882e28570e8a04f1c2d4500d5b Mon Sep 17 00:00:00 2001
06486d
From: Jakub Filak <jfilak@redhat.com>
06486d
Date: Mon, 27 Apr 2015 07:52:00 +0200
06486d
Subject: [ABRT PATCH] dbus: report invalid element names
06486d
06486d
Return D-Bus error in case of invalid problem element name.
06486d
06486d
Related: #1214451
06486d
06486d
Signed-off-by: Jakub Filak <jfilak@redhat.com>
06486d
---
06486d
 src/dbus/abrt-dbus.c | 14 +++++++++++++-
06486d
 1 file changed, 13 insertions(+), 1 deletion(-)
06486d
06486d
diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c
06486d
index 9e1844a..6de15e9 100644
06486d
--- a/src/dbus/abrt-dbus.c
06486d
+++ b/src/dbus/abrt-dbus.c
06486d
@@ -599,7 +599,7 @@ static void handle_method_call(GDBusConnection *connection,
06486d
 
06486d
         g_variant_get(parameters, "(&s&s&s)", &problem_id, &element, &value);
06486d
 
06486d
-        if (element == NULL || element[0] == '\0' || strlen(element) > 64)
06486d
+        if (!str_is_correct_filename(element))
06486d
         {
06486d
             log_notice("'%s' is not a valid element name of '%s'", element, problem_id);
06486d
             char *error = xasprintf(_("'%s' is not a valid element name"), element);
06486d
@@ -658,6 +658,18 @@ static void handle_method_call(GDBusConnection *connection,
06486d
 
06486d
         g_variant_get(parameters, "(&s&s)", &problem_id, &element);
06486d
 
06486d
+        if (!str_is_correct_filename(element))
06486d
+        {
06486d
+            log_notice("'%s' is not a valid element name of '%s'", element, problem_id);
06486d
+            char *error = xasprintf(_("'%s' is not a valid element name"), element);
06486d
+            g_dbus_method_invocation_return_dbus_error(invocation,
06486d
+                                              "org.freedesktop.problems.InvalidElement",
06486d
+                                              error);
06486d
+
06486d
+            free(error);
06486d
+            return;
06486d
+        }
06486d
+
06486d
         struct dump_dir *dd = open_directory_for_modification_of_element(
06486d
                                     invocation, caller_uid, problem_id, element);
06486d
         if (!dd)
06486d
-- 
06486d
1.8.3.1
06486d