]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wolfSSL: Add missing free calls for wolfSSL structs
authorJuliusz Sosinowicz <juliusz@wolfssl.com>
Thu, 28 Apr 2022 12:16:36 +0000 (14:16 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 1 May 2022 13:35:36 +0000 (16:35 +0300)
In some configurations the wc_Init*() functions may either allocate
memory or other system resources. These resources need to be freed.

Co-authored-by: JacobBarthelmeh <jacob@wolfssl.com>
Signed-off-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
src/crypto/crypto_wolfssl.c

index 1dddafed084af21d8e04f5403c6d9cc4202edfd7..546f1288292c667a52a945934002f50c9f807395 100644 (file)
@@ -85,6 +85,7 @@ int sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac)
                wc_ShaUpdate(&sha, addr[i], len[i]);
 
        wc_ShaFinal(&sha, mac);
+       wc_ShaFree(&sha);
 
        return 0;
 }
@@ -106,6 +107,7 @@ int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
                wc_Sha256Update(&sha256, addr[i], len[i]);
 
        wc_Sha256Final(&sha256, mac);
+       wc_Sha256Free(&sha256);
 
        return 0;
 }
@@ -128,6 +130,7 @@ int sha384_vector(size_t num_elem, const u8 *addr[], const size_t *len,
                wc_Sha384Update(&sha384, addr[i], len[i]);
 
        wc_Sha384Final(&sha384, mac);
+       wc_Sha384Free(&sha384);
 
        return 0;
 }
@@ -150,6 +153,7 @@ int sha512_vector(size_t num_elem, const u8 *addr[], const size_t *len,
                wc_Sha512Update(&sha512, addr[i], len[i]);
 
        wc_Sha512Final(&sha512, mac);
+       wc_Sha512Free(&sha512);
 
        return 0;
 }
@@ -177,6 +181,8 @@ static int wolfssl_hmac_vector(int type, const u8 *key,
                        return -1;
        if (wc_HmacFinal(&hmac, mac) != 0)
                return -1;
+       wc_HmacFree(&hmac);
+
        return 0;
 }