daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
84b277
From 48a85bb45ff9d3ee302594ac41d102fa16b31350 Mon Sep 17 00:00:00 2001
84b277
From: Michal Sekletar <msekleta@redhat.com>
84b277
Date: Sat, 27 Sep 2014 20:40:11 +0200
84b277
Subject: [PATCH] dbus: fix crash when appending selinux context
84b277
84b277
RHEL-only
84b277
84b277
Related: #1113790
84b277
---
84b277
 src/core/dbus-execute.c | 11 +++++++++--
84b277
 1 file changed, 9 insertions(+), 2 deletions(-)
84b277
84b277
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
84b277
index 8162f1c..ae65be1 100644
84b277
--- a/src/core/dbus-execute.c
84b277
+++ b/src/core/dbus-execute.c
84b277
@@ -376,6 +376,7 @@ static int bus_execute_append_selinux_context(DBusMessageIter *i, const char *pr
84b277
         ExecContext *c = data;
84b277
         dbus_bool_t selinux_context_ignore;
84b277
         const char *selinux_context = NULL;
84b277
+        DBusMessageIter sub;
84b277
 
84b277
         assert(i);
84b277
         assert(property);
84b277
@@ -387,10 +388,16 @@ static int bus_execute_append_selinux_context(DBusMessageIter *i, const char *pr
84b277
 
84b277
         selinux_context_ignore = c->selinux_context_ignore;
84b277
 
84b277
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &selinux_context_ignore))
84b277
+        if (!dbus_message_iter_open_container(i, DBUS_TYPE_STRUCT, NULL, &sub))
84b277
+                return -ENOMEM;
84b277
+
84b277
+        if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_BOOLEAN, &selinux_context_ignore))
84b277
                 return -ENOMEM;
84b277
 
84b277
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &selinux_context))
84b277
+        if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &selinux_context))
84b277
+                return -ENOMEM;
84b277
+
84b277
+        if (!dbus_message_iter_close_container(i, &sub))
84b277
                 return -ENOMEM;
84b277
 
84b277
         return 0;