From: Remi Tricot-Le Breton Date: Tue, 20 Oct 2026 08:04:46 +0000 (+0200) Subject: BUG/MINOR: jws: fix ECDSA_SIG leak in jws_b64_signature() X-Git-Tag: v3.5-dev10~83 X-Git-Url: https://git.kaiwu.me/$%7BGITURL%7D/doc/static/gitweb.js?a=commitdiff_plain;h=f563e836297c05f63698aa54d5a9154d0abf6b2a;p=haproxy.git BUG/MINOR: jws: fix ECDSA_SIG leak in jws_b64_signature() In 'jws_b64_signature' we call 'd2i_ECDSA_SIG' which creates an ECDSA_SIG object that was never freed. This was introduced in 3.2 by commit 3abb428fc ("MINOR: jws: implement JWS signing"), so the fix must be backported to 3.2. --- diff --git a/src/jws.c b/src/jws.c index 769a74b1e..4d4d3070e 100644 --- a/src/jws.c +++ b/src/jws.c @@ -354,6 +354,7 @@ size_t jws_b64_signature(EVP_PKEY *pkey, enum jwt_alg alg, char *b64protected, c { EVP_MD_CTX *ctx = NULL; const EVP_MD *evp_md = NULL; + ECDSA_SIG *sig = NULL; int ret = 0; struct buffer *sign = NULL; size_t out_sign_len = 0; @@ -416,7 +417,6 @@ size_t jws_b64_signature(EVP_PKEY *pkey, enum jwt_alg alg, char *b64protected, c /* Convert the DigestSign output to an ECDSA_SIG (R and S parameters concatenated, * see section 3.4 of RFC7518), and output R and S padded. */ - ECDSA_SIG *sig = NULL; const BIGNUM *r = NULL, *s = NULL; int bignum_len; @@ -448,6 +448,7 @@ size_t jws_b64_signature(EVP_PKEY *pkey, enum jwt_alg alg, char *b64protected, c out: EVP_MD_CTX_free(ctx); free_trash_chunk(sign); + ECDSA_SIG_free(sig); if (ret > 0) return ret;