From 0017081d78dafbea4602229898ed41e2d6ab6283 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 25 Jan 2017 23:32:57 +0000 Subject: [PATCH] xrdp-sesadmin: fix crash on network or authentication error If scp_v1c_mng_get_session_list() returns an error, report it to the user and exit. Session list is not initialized in that case and should not be freed. g_free() already checks its argument for being to NULL, remove an extra check. --- sesman/tools/sesadmin.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c index 7d66ad2e..b76b407e 100644 --- a/sesman/tools/sesadmin.c +++ b/sesman/tools/sesadmin.c @@ -196,7 +196,13 @@ void cmndList(struct SCP_CONNECTION *c) e = scp_v1c_mng_get_session_list(c, &scnt, &dsl); - if ((SCP_CLIENT_STATE_LIST_OK == e) && (scnt > 0)) + if (e != SCP_CLIENT_STATE_LIST_OK) + { + printf("Error getting session list.\n"); + return; + } + + if (scnt > 0) { for (idx = 0; idx < scnt; idx++) { @@ -211,10 +217,7 @@ void cmndList(struct SCP_CONNECTION *c) printf("No sessions.\n"); } - if (0 != dsl) - { - g_free(dsl); - } + g_free(dsl); } void cmndKill(struct SCP_CONNECTION *c, struct SCP_SESSION *s)