From: Emmanuel Deloget Date: Mon, 12 Jun 2017 13:43:30 +0000 (+0200) Subject: OpenSSL: force meth->name as non-const when we free() it X-Git-Tag: v2.5_beta1~669 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fd07c31fe8878dc75e760d151d291379c0f8743;p=thirdparty%2Fopenvpn.git OpenSSL: force meth->name as non-const when we free() it We are in control of meth->name (we string_alloc() it in RSA_meth_new()) so we know that we can free() it when it's no longer needed. Yet we have to force the value to be non-const to avoid a compiler warning -- due to the fact that OpenSSL defines the value as a const char*, regardless of its origin. Acked-by: Steffan Karger Message-Id: <20170612134330.20971-9-logout@free.fr> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14798.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h index 729fab6c5..eeacb525d 100644 --- a/src/openvpn/openssl_compat.h +++ b/src/openvpn/openssl_compat.h @@ -349,7 +349,13 @@ RSA_meth_free(RSA_METHOD *meth) { if (meth) { - free(meth->name); + /* OpenSSL defines meth->name to be a const pointer, yet we + * feed it with an allocated string (from RSA_meth_new()). + * Thus we are allowed to free it here. In order to avoid a + * "passing 'const char *' to parameter of type 'void *' discards + * qualifiers" warning, we force the pointer to be a non-const value. + */ + free((char *)meth->name); free(meth); } }