]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - ssl/ssl_lib.c
Since return is inconsistent, I removed unnecessary parentheses and
[thirdparty/openssl.git] / ssl / ssl_lib.c
index cc110bc6770f43d5caaec9a577138541bc41e582..9fec761714ef935ac33caa9e02df80f207a69ed6 100644 (file)
@@ -12,7 +12,6 @@
 #include <stdio.h>
 #include "ssl_locl.h"
 #include <openssl/objects.h>
-#include <openssl/lhash.h>
 #include <openssl/x509v3.h>
 #include <openssl/rand.h>
 #include <openssl/ocsp.h>
@@ -161,6 +160,7 @@ static int ssl_dane_dup(SSL *to, SSL *from)
     if (!DANETLS_ENABLED(&from->dane))
         return 1;
 
+    num = sk_danetls_record_num(from->dane.trecs);
     dane_final(&to->dane);
     to->dane.flags = from->dane.flags;
     to->dane.dctx = &to->ctx->dane;
@@ -170,8 +170,9 @@ static int ssl_dane_dup(SSL *to, SSL *from)
         SSLerr(SSL_F_SSL_DANE_DUP, ERR_R_MALLOC_FAILURE);
         return 0;
     }
+    if (!sk_danetls_record_reserve(to->dane.trecs, num))
+        return 0;
 
-    num = sk_danetls_record_num(from->dane.trecs);
     for (i = 0; i < num; ++i) {
         danetls_record *t = sk_danetls_record_value(from->dane.trecs, i);
 
@@ -440,8 +441,8 @@ static int ssl_check_allowed_versions(int min_version, int max_version)
         if (min_version == DTLS1_VERSION)
             min_version = DTLS1_2_VERSION;
 #endif
-       /* Done massaging versions; do the check. */
-       if (0
+        /* Done massaging versions; do the check. */
+        if (0
 #ifdef OPENSSL_NO_DTLS1
             || (DTLS_VERSION_GE(min_version, DTLS1_VERSION)
                 && DTLS_VERSION_GE(DTLS1_VERSION, max_version))
@@ -454,44 +455,44 @@ static int ssl_check_allowed_versions(int min_version, int max_version)
             return 0;
     } else {
         /* Regular TLS version checks. */
-       if (min_version == 0)
-           min_version = SSL3_VERSION;
-       if (max_version == 0)
-           max_version = TLS1_3_VERSION;
+        if (min_version == 0)
+            min_version = SSL3_VERSION;
+        if (max_version == 0)
+            max_version = TLS1_3_VERSION;
 #ifdef OPENSSL_NO_TLS1_3
-       if (max_version == TLS1_3_VERSION)
-           max_version = TLS1_2_VERSION;
+        if (max_version == TLS1_3_VERSION)
+            max_version = TLS1_2_VERSION;
 #endif
 #ifdef OPENSSL_NO_TLS1_2
-       if (max_version == TLS1_2_VERSION)
-           max_version = TLS1_1_VERSION;
+        if (max_version == TLS1_2_VERSION)
+            max_version = TLS1_1_VERSION;
 #endif
 #ifdef OPENSSL_NO_TLS1_1
-       if (max_version == TLS1_1_VERSION)
-           max_version = TLS1_VERSION;
+        if (max_version == TLS1_1_VERSION)
+            max_version = TLS1_VERSION;
 #endif
 #ifdef OPENSSL_NO_TLS1
-       if (max_version == TLS1_VERSION)
-           max_version = SSL3_VERSION;
+        if (max_version == TLS1_VERSION)
+            max_version = SSL3_VERSION;
 #endif
 #ifdef OPENSSL_NO_SSL3
-       if (min_version == SSL3_VERSION)
-           min_version = TLS1_VERSION;
+        if (min_version == SSL3_VERSION)
+            min_version = TLS1_VERSION;
 #endif
 #ifdef OPENSSL_NO_TLS1
-       if (min_version == TLS1_VERSION)
-           min_version = TLS1_1_VERSION;
+        if (min_version == TLS1_VERSION)
+            min_version = TLS1_1_VERSION;
 #endif
 #ifdef OPENSSL_NO_TLS1_1
-       if (min_version == TLS1_1_VERSION)
-           min_version = TLS1_2_VERSION;
+        if (min_version == TLS1_1_VERSION)
+            min_version = TLS1_2_VERSION;
 #endif
 #ifdef OPENSSL_NO_TLS1_2
-       if (min_version == TLS1_2_VERSION)
-           min_version = TLS1_3_VERSION;
+        if (min_version == TLS1_2_VERSION)
+            min_version = TLS1_3_VERSION;
 #endif
-       /* Done massaging versions; do the check. */
-       if (0
+        /* Done massaging versions; do the check. */
+        if (0
 #ifdef OPENSSL_NO_SSL3
             || (min_version <= SSL3_VERSION && SSL3_VERSION <= max_version)
 #endif
@@ -603,7 +604,7 @@ int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth)
         SSLerr(SSL_F_SSL_CTX_SET_SSL_VERSION, SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS);
         return (0);
     }
-    return (1);
+    return 1;
 }
 
 SSL *SSL_new(SSL_CTX *ctx)
@@ -719,7 +720,8 @@ SSL *SSL_new(SSL_CTX *ctx)
     if (ctx->ext.supportedgroups) {
         s->ext.supportedgroups =
             OPENSSL_memdup(ctx->ext.supportedgroups,
-                           ctx->ext.supportedgroups_len);
+                           ctx->ext.supportedgroups_len
+                                * sizeof(*ctx->ext.supportedgroups));
         if (!s->ext.supportedgroups)
             goto err;
         s->ext.supportedgroups_len = ctx->ext.supportedgroups_len;
@@ -2737,9 +2739,9 @@ static unsigned long ssl_session_hash(const SSL_SESSION *a)
 static int ssl_session_cmp(const SSL_SESSION *a, const SSL_SESSION *b)
 {
     if (a->ssl_version != b->ssl_version)
-        return (1);
+        return 1;
     if (a->session_id_length != b->session_id_length)
-        return (1);
+        return 1;
     return (memcmp(a->session_id, b->session_id, a->session_id_length));
 }