From 27dc867671d7dab44156f68d6ba52467a324bf78 Mon Sep 17 00:00:00 2001 From: eugen-keeper Date: Tue, 7 Jan 2025 18:53:04 +0000 Subject: [PATCH] GUACAMOLE-2012: Fix a size calculation issue --- src/common-ssh/ssh.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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++; }