]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
mbedtls: fix segfault by calling mbedtls_cipher_free() in cipher_ctx_free()
authorAntonio Quartulli <a@unstable.cc>
Fri, 16 Aug 2019 20:49:45 +0000 (22:49 +0200)
committerGert Doering <gert@greenie.muc.de>
Sat, 17 Aug 2019 18:08:29 +0000 (20:08 +0200)
Commit ("openssl: Fix compilation without deprecated OpenSSL 1.1 APIs")
has removed the cipher_ctx_cleanup() API, as it is not anymore required
to be a distinct call. However, while doing so it also touched the
mbedtls backend in a wrong way causing a systematic segfault upon
connection.

Basically mbedtls_cipher_free(ctx) was moved from the defunct
cipher_ctx_cleanup()
to md_ctx_free(), while it was supposed to go into cipher_ctx_free().
This was clearly wrong as also the type of the ctx variable was not
correct anymore.

Fix this mistake by actually moving mbedtls_cipher_free(ctx) to
cipher_ctx_free().

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20190816204945.7937-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18781.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/crypto_mbedtls.c

index f924323d115f9f8d1323706631ff5b3d9a55a251..648a988e89dda42a9fbb58d3dd85d807080a2eab 100644 (file)
@@ -591,6 +591,7 @@ cipher_ctx_new(void)
 void
 cipher_ctx_free(mbedtls_cipher_context_t *ctx)
 {
+    mbedtls_cipher_free(ctx);
     free(ctx);
 }
 
@@ -855,7 +856,6 @@ md_ctx_new(void)
 void
 md_ctx_free(mbedtls_md_context_t *ctx)
 {
-    mbedtls_cipher_free(ctx);
     free(ctx);
 }