diff --git a/src/common-ssh/ssh.c b/src/common-ssh/ssh.c index dabb71b83..b20750e3a 100644 --- a/src/common-ssh/ssh.c +++ b/src/common-ssh/ssh.c @@ -457,8 +457,8 @@ static char *get_method_pref_string(guac_client* client, LIBSSH2_SESSION* sessio } if (found || supported_algs_count <= 0) { bool req_comma = algs_str[0] != 0; - int req_size = strlen(algs_str) + strlen(algs[i]) + (req_comma ? 1 : 0) + 1; - if (req_size > algs_str_size) { + int req_size = strlen(algs[i]) + (req_comma ? 1 : 0) + 1; + if (strlen(algs_str) + req_size > algs_str_size) { algs_str_size += MAX(req_size, 1024); algs_str = guac_mem_realloc(algs_str, algs_str_size); } @@ -467,8 +467,8 @@ static char *get_method_pref_string(guac_client* client, LIBSSH2_SESSION* sessio } strcat(algs_str, algs[i]); } else { - guac_client_log(client, GUAC_LOG_WARNING, - "Preferred algorithm/cipher '%s' is not supported by libssh2", algs[i]); + guac_client_log(client, GUAC_LOG_WARNING, + "Preferred algorithm/cipher '%s' is not supported by libssh2", algs[i]); } i++; }