]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
openssl: remove usage of OPENSSL_malloc() from show_available_curves
authorSteffan Karger <steffan@karger.me>
Tue, 20 Oct 2015 22:39:04 +0000 (00:39 +0200)
committerGert Doering <gert@greenie.muc.de>
Thu, 22 Oct 2015 17:53:36 +0000 (19:53 +0200)
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 <steffan@karger.me>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1445380744-21086-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10339
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/ssl_openssl.c

index c08d4fe41e68a82ae176bf518d0a2ba7e12cddd3..c5543fe1c1a79e6d360e6a4f44409d105400de49 100644 (file)
@@ -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.");