ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
Blob Blame History Raw
From 48a85bb45ff9d3ee302594ac41d102fa16b31350 Mon Sep 17 00:00:00 2001
From: Michal Sekletar <msekleta@redhat.com>
Date: Sat, 27 Sep 2014 20:40:11 +0200
Subject: [PATCH] dbus: fix crash when appending selinux context

RHEL-only

Related: #1113790
---
 src/core/dbus-execute.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 8162f1c..ae65be1 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -376,6 +376,7 @@ static int bus_execute_append_selinux_context(DBusMessageIter *i, const char *pr
         ExecContext *c = data;
         dbus_bool_t selinux_context_ignore;
         const char *selinux_context = NULL;
+        DBusMessageIter sub;
 
         assert(i);
         assert(property);
@@ -387,10 +388,16 @@ static int bus_execute_append_selinux_context(DBusMessageIter *i, const char *pr
 
         selinux_context_ignore = c->selinux_context_ignore;
 
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &selinux_context_ignore))
+        if (!dbus_message_iter_open_container(i, DBUS_TYPE_STRUCT, NULL, &sub))
+                return -ENOMEM;
+
+        if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_BOOLEAN, &selinux_context_ignore))
                 return -ENOMEM;
 
-        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &selinux_context))
+        if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &selinux_context))
+                return -ENOMEM;
+
+        if (!dbus_message_iter_close_container(i, &sub))
                 return -ENOMEM;
 
         return 0;