]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl: fix possible ctx memory leak in sample_conv_aes_gcm()
authorDragan Dosen <ddosen@haproxy.com>
Mon, 11 Mar 2024 17:10:01 +0000 (18:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 11 Mar 2024 18:20:31 +0000 (19:20 +0100)
The issue was introduced with the commit c31499d74 ("MINOR: ssl: Add
aes_gcm_dec converter").

This must be backported to all stable branches where the above converter
is present, but it may need to be adjusted for older branches because of
code refactoring.

src/ssl_sample.c

index 42d60ac9dad86143a1534101b56aab07dfda685c..abe616025a24630323f28c676d8a8b90bbc08013 100644 (file)
@@ -280,7 +280,7 @@ static int sample_conv_aes_gcm(const struct arg *arg_p, struct sample *smp, void
 {
        struct sample nonce, key, aead_tag;
        struct buffer *smp_trash = NULL, *smp_trash_alloc = NULL;
-       EVP_CIPHER_CTX *ctx;
+       EVP_CIPHER_CTX *ctx = NULL;
        int size, ret, dec;
 
        smp_trash_alloc = alloc_trash_chunk();
@@ -407,11 +407,13 @@ static int sample_conv_aes_gcm(const struct arg *arg_p, struct sample *smp, void
        smp_dup(smp);
        free_trash_chunk(smp_trash_alloc);
        free_trash_chunk(smp_trash);
+       EVP_CIPHER_CTX_free(ctx);
        return 1;
 
 err:
        free_trash_chunk(smp_trash_alloc);
        free_trash_chunk(smp_trash);
+       EVP_CIPHER_CTX_free(ctx);
        return 0;
 }
 #endif