From: Juliusz Sosinowicz Date: Thu, 28 Apr 2022 12:16:36 +0000 (+0200) Subject: wolfSSL: Add missing free calls for wolfSSL structs X-Git-Tag: hostap_2_11~1979 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f7e10177a7687526ebd5ff0d72a3974b7c91687;p=thirdparty%2Fhostap.git wolfSSL: Add missing free calls for wolfSSL structs 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 Signed-off-by: Juliusz Sosinowicz --- diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c index 1dddafed0..546f12882 100644 --- a/src/crypto/crypto_wolfssl.c +++ b/src/crypto/crypto_wolfssl.c @@ -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; }