From 05dfb1a6ae931564458ba6f66360bd12a9ae783f Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sun, 25 Jun 2017 04:49:05 -0400 Subject: [PATCH] GUACAMOLE-203: Deal correctly with negative keepalive values. --- src/common-ssh/ssh.c | 14 +++++++++----- src/protocols/rdp/rdp_settings.h | 2 +- src/protocols/ssh/settings.h | 2 +- src/protocols/vnc/settings.h | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c index 50ab7e0b..d7da64a8 100644 --- a/src/common-ssh/ssh.c +++ b/src/common-ssh/ssh.c @@ -532,16 +532,20 @@ guac_common_ssh_session* guac_common_ssh_create_session(guac_client* client, return NULL; } - /* Configure session keepalive */ - if (keepalive > 0) - libssh2_keepalive_config(common_session->session, 1, keepalive); - /* Warn if keepalive below minimum value */ - if (keepalive == 1) { + if (keepalive < 0) { + keepalive = 0; + guac_client_log(client, GUAC_LOG_WARNING, "negative keepalive intervals " + "are converted to 0, disabling keepalive."); + } + else if(keepalive == 1) { guac_client_log(client, GUAC_LOG_WARNING, "keepalive interval will " "be rounded up to minimum value of 2."); } + /* Configure session keepalive */ + libssh2_keepalive_config(common_session->session, 1, keepalive); + /* Return created session */ return common_session; diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h index e2013b7b..8edb79e4 100644 --- a/src/protocols/rdp/rdp_settings.h +++ b/src/protocols/rdp/rdp_settings.h @@ -366,7 +366,7 @@ typedef struct guac_rdp_settings { * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner * cases. */ - unsigned sftp_server_alive_interval; + int sftp_server_alive_interval; #endif /** diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index ea9f5ace..f49d054d 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -189,7 +189,7 @@ typedef struct guac_ssh_settings { /** * The number of seconds between sending server alive messages. */ - unsigned server_alive_interval; + int server_alive_interval; } guac_ssh_settings; diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h index a9ce82c5..3c7b2587 100644 --- a/src/protocols/vnc/settings.h +++ b/src/protocols/vnc/settings.h @@ -180,7 +180,7 @@ typedef struct guac_vnc_settings { * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner * cases. */ - unsigned sftp_server_alive_interval; + int sftp_server_alive_interval; #endif /**