summaryrefslogtreecommitdiffstats
path: root/sesman/libscp
diff options
context:
space:
mode:
authorBen Cohen <ben-cohen@users.noreply.github.com>2017-07-05 20:39:01 +0100
committermetalefty <meta@vmeta.jp>2017-07-06 13:40:25 +0900
commitc7d08bd9e7bcd00b11328537319ec7748a797574 (patch)
treed9c166ca57d150d516ed6e17aa9b0496bd4c5a88 /sesman/libscp
parentaa4b90d250c5e814372751007c2f8cb2e9bae629 (diff)
downloadxrdp-proprietary-c7d08bd9e7bcd00b11328537319ec7748a797574.tar.gz
xrdp-proprietary-c7d08bd9e7bcd00b11328537319ec7748a797574.zip
xrdp-sesadmin: fix error when there are no sessions
Test case: On a system running xrdp with no sessions running run: xrdp-sesadmin -u=<user> -p=<password> -c=list Expected result: "No sessions." (ignoring debug output) Observed result: "Error getting session list." In the SCP_SERVER_STATE_MNG_LISTREQ case in scp_v1_mng_process() if there are no sessions it ends the scp session, which causes an error in the client. In commit 0017081d the client was changed to report errors, giving the result above. Fix by calling scp_v1s_mng_list_sessions() from scp_v1_mng_process() even when there are no sessions, and if so sending a packet with a count of zero so that the client gets what it expects.
Diffstat (limited to 'sesman/libscp')
-rw-r--r--sesman/libscp/libscp_v1s_mng.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sesman/libscp/libscp_v1s_mng.c b/sesman/libscp/libscp_v1s_mng.c
index 9c31cec6..3a3e1d98 100644
--- a/sesman/libscp/libscp_v1s_mng.c
+++ b/sesman/libscp/libscp_v1s_mng.c
@@ -188,11 +188,18 @@ scp_v1s_mng_list_sessions(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
struct SCP_DISCONNECTED_SESSION *cds;
/* calculating the number of packets to send */
- pktcnt = sescnt / SCP_SERVER_MAX_LIST_SIZE;
-
- if ((sescnt % SCP_SERVER_MAX_LIST_SIZE) != 0)
+ if (sescnt == 0)
+ {
+ pktcnt = 1;
+ }
+ else
{
- pktcnt++;
+ pktcnt = sescnt / SCP_SERVER_MAX_LIST_SIZE;
+
+ if ((sescnt % SCP_SERVER_MAX_LIST_SIZE) != 0)
+ {
+ pktcnt++;
+ }
}
for (idx = 0; idx < pktcnt; idx++)