[Spice-devel] [vdagent-linux v2 4/6] console-kit: do not use empty session

Victor Toso victortoso at redhat.com
Sat Apr 23 10:27:51 UTC 2016


DBus might return empty string for active-session, probably in a non user
session (e.g. gdm). It is better to keep the variable as NULL as we check
against that (but never against empty strings).
---
 src/console-kit.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/console-kit.c b/src/console-kit.c
index fc73cf2..7096609 100644
--- a/src/console-kit.c
+++ b/src/console-kit.c
@@ -358,7 +358,12 @@ static char *console_kit_check_active_session_change(struct session_info *si)
         }
 
         dbus_message_iter_get_basic(&iter, &session);
-        si->active_session = strdup(session);
+        if (session != NULL && session[0] != '\0') {
+            si->active_session = strdup(session);
+        } else if (si->verbose) {
+            syslog(LOG_WARNING, "(console-kit) received invalid session. "
+                   "No active-session at the moment");
+        }
         dbus_message_unref(message);
 
         /* non blocking read of the next available message */
-- 
2.5.5



More information about the Spice-devel mailing list