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

Victor Toso victortoso at redhat.com
Thu Apr 28 13:33:03 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 9da1165..3a72657 100644
--- a/src/console-kit.c
+++ b/src/console-kit.c
@@ -357,7 +357,12 @@ static char *console_kit_check_active_session_change(struct session_info *info)
         }
 
         dbus_message_iter_get_basic(&iter, &session);
-        info->active_session = strdup(session);
+        if (session != NULL && session[0] != '\0') {
+            info->active_session = strdup(session);
+        } else {
+            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