]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OpenSSL: Fix a memory leak on an error path
authorJouni Malinen <quic_jouni@quicinc.com>
Mon, 22 Jan 2024 17:12:12 +0000 (19:12 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 22 Jan 2024 19:16:47 +0000 (21:16 +0200)
peerkey from EVP_PKEY_new() needs to be freed on all error paths.

Fixes: b062507670b5 ("OpenSSL: Implement crypto_ecdh routines without EC_KEY for OpenSSL 3.0")
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/crypto/crypto_openssl.c

index d10949ce7cc19c1519fe61266c2df67bdb68bd2d..30aaef561953ff93496ec361bca6dc205285b793 100644 (file)
@@ -2854,8 +2854,10 @@ struct wpabuf * crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y,
 
        /* Encode using SECG SEC 1, Sec. 2.3.4 format */
        peer = os_malloc(1 + len);
-       if (!peer)
+       if (!peer) {
+               EVP_PKEY_free(peerkey);
                return NULL;
+       }
        peer[0] = inc_y ? 0x04 : 0x02;
        os_memcpy(peer + 1, key, len);