On 12-06-17 15:43, log...@free.fr wrote: > From: Emmanuel Deloget <log...@free.fr> > > 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. > --- > src/openvpn/openssl_compat.h | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h > index 71ecfc06..69db6fb5 100644 > --- a/src/openvpn/openssl_compat.h > +++ b/src/openvpn/openssl_compat.h > @@ -493,7 +493,12 @@ 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 > + * ‘free’ discards ‘const’ warning, we force the pointer to > + * be a non-const value. */ > + free((char *)meth->name); > free(meth); > } > } >
Silences the warning and explains why the code does what it does, which I agree is the correct way to work around OpenSSL API funkyness. ACK -Steffan ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel