From: Holger Dengler Date: Mon, 11 Nov 2024 10:29:12 +0000 (+0100) Subject: Fix memleaks in cmd_RecordPadding() X-Git-Tag: openssl-3.4.1~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4393fdd4a72d9a6f6d9b06528a0ebc9ec46d72d3;p=thirdparty%2Fopenssl.git Fix memleaks in cmd_RecordPadding() Free the internal copy of parameter `value` on each early exit. Fixes #25906 Signed-off-by: Holger Dengler Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/25926) (cherry picked from commit 0abbd3e5ac0a3a7af69849b1a5010b4f0616ca37) --- diff --git a/ssl/ssl_conf.c b/ssl/ssl_conf.c index 5e2d7c1c98d..e5465dbc511 100644 --- a/ssl/ssl_conf.c +++ b/ssl/ssl_conf.c @@ -664,22 +664,19 @@ static int cmd_RecordPadding(SSL_CONF_CTX *cctx, const char *value) copy = OPENSSL_strdup(value); if (copy == NULL) - return 0; + goto out; commap = strstr(copy, ","); if (commap != NULL) { *commap = '\0'; - if (*(commap + 1) == '\0') { - OPENSSL_free(copy); - return 0; - } + if (*(commap + 1) == '\0') + goto out; if (!OPENSSL_strtoul(commap + 1, &endptr, 0, &hs_padding)) - return 0; + goto out; } if (!OPENSSL_strtoul(copy, &endptr, 0, &block_padding)) - return 0; + goto out; if (commap == NULL) hs_padding = block_padding; - OPENSSL_free(copy); /* * All we care about are non-negative values, @@ -691,6 +688,8 @@ static int cmd_RecordPadding(SSL_CONF_CTX *cctx, const char *value) if (cctx->ssl) rv = SSL_set_block_padding_ex(cctx->ssl, (size_t)block_padding, (size_t)hs_padding); +out: + OPENSSL_free(copy); return rv; }