openssl: remove usage of OPENSSL_malloc() from show_available_curves
PATCH 1/1 openssl: remove usage of OPENSSL_malloc() from show_available_curves
There is no need to use OPENSSL_malloc(), so use our own functions that automatically check for NULL and remove the now redundant NULL check.
Signed-off-by Steffan Karger <[email protected]...>
--- src/openvpn/ssl_openssl.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
src/openvpn/ssl_openssl.c +13 -20
@@ -1447,31 +1447,24 @@ show_available_curves()size_t n =0 ; crv_len =EC_get_builtin_curves (NULL ,0 ); - - curves =OPENSSL_malloc ((int )(sizeof (EC_builtin_curve) * crv_len)); - -if (curves ==NULL ) -crypto_msg (M_FATAL ,"Cannot create EC_builtin_curve object" ); -else +ALLOC_ARRAY (curves, EC_builtin_curve, crv_len); +if (EC_get_builtin_curves (curves, crv_len)) { -if (EC_get_builtin_curves (curves, crv_len)) +printf ("Available Elliptic curves:\n" ); +for (n =0 ; n < crv_len; n++) { -printf ("Available Elliptic curves:\n" ); -for (n =0 ; n < crv_len; n++) - { -const char *sname; - sname =OBJ_nid2sn (curves[n].nid); -if (sname ==NULL ) sname ="" ; +const char *sname; + sname =OBJ_nid2sn (curves[n].nid); +if (sname ==NULL ) sname ="" ; -printf ("%s\n" , sname); - } +printf ("%s\n" , sname); } -else - { -crypto_msg (M_FATAL ,"Cannot get list of builtin curves" ); - } -OPENSSL_free (curves); } +else + { +crypto_msg (M_FATAL ,"Cannot get list of builtin curves" ); + } +free (curves);#else msg (M_WARN ,"Your OpenSSL library was built without elliptic curve support. " "No curves available." );
Signature · 1 line
2.1.4
ACK from me. Less code is better.
Quoted 58 lines · Steffan Karger
There is no need to use
OPENSSL_malloc(), so use our own functions that automatically check for NULL and remove the now redundant NULL check.Signed-off-by Steffan Karger <[email protected]...>--- src/openvpn/ssl_openssl.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)src/openvpn/ssl_openssl.c +13
-20@@ -1447,31 +1447,24 @@ show_available_curves()size_t n =0 ; crv_len =EC_get_builtin_curves (NULL ,0 ); - - curves =OPENSSL_malloc ((int )(sizeof (EC_builtin_curve) * crv_len)); - -if (curves ==NULL ) -crypto_msg (M_FATAL ,"Cannot create EC_builtin_curve object" ); -else +ALLOC_ARRAY (curves, EC_builtin_curve, crv_len); +if (EC_get_builtin_curves (curves, crv_len)) { -if (EC_get_builtin_curves (curves, crv_len)) +printf ("Available Elliptic curves:\n" ); +for (n =0 ; n < crv_len; n++) { -printf ("Available Elliptic curves:\n" ); -for (n =0 ; n < crv_len; n++) - { -const char *sname; - sname =OBJ_nid2sn (curves[n].nid); -if (sname ==NULL ) sname ="" ; +const char *sname; + sname =OBJ_nid2sn (curves[n].nid); +if (sname ==NULL ) sname ="" ; -printf ("%s\n" , sname); - } +printf ("%s\n" , sname); } -else - { -crypto_msg (M_FATAL ,"Cannot get list of builtin curves" ); - } -OPENSSL_free (curves); } +else + { +crypto_msg (M_FATAL ,"Cannot get list of builtin curves" ); + } +free (curves);#else msg (M_WARN ,"Your OpenSSL library was built without elliptic curve support. " "No curves available." );
Your patch has been applied to the master branch.
commit 470eb8b6b6a9970a68cb17a185359adffbaeabf5
Author: Steffan Karger Date: Wed Oct 21 00:39:04 2015 +0200
openssl: remove usage of OPENSSL_malloc() from show_available_curves
Signed-off-by: Steffan Karger <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10339
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering