reject zero length point format list or supported curves extensions
[openssl.git] / ssl / t1_lib.c
index 254221bcf9d4405c881090d77fd53fffa2b305bd..fd13a317c16d9f7676327622e7aef09bbd23807d 100644 (file)
@@ -525,6 +525,8 @@ int tls1_set_curves_list(unsigned char **pext, size_t *pextlen,
        ncb.nidcnt = 0;
        if (!CONF_parse_list(str, ':', 1, nid_cb, &ncb))
                return 0;
+       if (pext == NULL)
+               return 1;
        return tls1_set_curves(pext, pextlen, ncb.nid_arr, ncb.nidcnt);
        }
 /* For an EC key set TLS id and required compression based on parameters */
@@ -688,7 +690,7 @@ int tls1_check_ec_tmp_key(SSL *s, unsigned long cid)
        EC_KEY *ec = s->cert->ecdh_tmp;
 #ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
        /* Allow any curve: not just those peer supports */
-       if (s->cert->cert_flags & SSL_CERT_FLAG_BROKEN_PROTCOL)
+       if (s->cert->cert_flags & SSL_CERT_FLAG_BROKEN_PROTOCOL)
                return 1;
 #endif
        /* If Suite B, AES128 MUST use P-256 and AES256 MUST use P-384,
@@ -1851,7 +1853,8 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char
                        unsigned char *sdata = data;
                        int ecpointformatlist_length = *(sdata++);
 
-                       if (ecpointformatlist_length != size - 1)
+                       if (ecpointformatlist_length != size - 1 || 
+                               ecpointformatlist_length < 1)
                                {
                                *al = TLS1_AD_DECODE_ERROR;
                                return 0;
@@ -1887,7 +1890,8 @@ static int ssl_scan_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char
                        int ellipticcurvelist_length = (*(sdata++) << 8);
                        ellipticcurvelist_length += (*(sdata++));
 
-                       if (ellipticcurvelist_length != size - 2)
+                       if (ellipticcurvelist_length != size - 2 ||
+                               ellipticcurvelist_length < 1)
                                {
                                *al = TLS1_AD_DECODE_ERROR;
                                return 0;
@@ -2755,6 +2759,18 @@ int ssl_check_clienthello_tlsext_late(SSL *s)
        if ((s->tlsext_status_type != -1) && s->ctx && s->ctx->tlsext_status_cb)
                {
                int r;
+               CERT_PKEY *certpkey;
+               certpkey = ssl_get_server_send_pkey(s);
+               /* If no certificate can't return certificate status */
+               if (certpkey == NULL)
+                       {
+                       s->tlsext_status_expected = 0;
+                       return 1;
+                       }
+               /* Set current certificate to one we will use so
+                * SSL_get_certificate et al can pick it up.
+                */
+               s->cert->key = certpkey;
                r = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg);
                switch (r)
                        {
@@ -3422,7 +3438,7 @@ int tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize)
        tls1_set_shared_sigalgs(s);
 
 #ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
-       if (s->cert->cert_flags & SSL_CERT_FLAG_BROKEN_PROTCOL)
+       if (s->cert->cert_flags & SSL_CERT_FLAG_BROKEN_PROTOCOL)
                {
                /* Use first set signature preference to force message
                 * digest, ignoring any peer preferences.
@@ -3742,6 +3758,8 @@ int tls1_set_sigalgs_list(CERT *c, const char *str, int client)
        sig.sigalgcnt = 0;
        if (!CONF_parse_list(str, ':', 1, sig_cb, &sig))
                return 0;
+       if (c == NULL)
+               return 1;
        return tls1_set_sigalgs(c, sig.sigalgs, sig.sigalgcnt, client);
        }
 
@@ -3862,7 +3880,7 @@ int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain,
                        goto end;
 #ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
                /* Allow any certificate to pass test */
-               if (s->cert->cert_flags & SSL_CERT_FLAG_BROKEN_PROTCOL)
+               if (s->cert->cert_flags & SSL_CERT_FLAG_BROKEN_PROTOCOL)
                        {
                        rv = CERT_PKEY_STRICT_FLAGS|CERT_PKEY_EXPLICIT_SIGN|CERT_PKEY_VALID|CERT_PKEY_SIGN;
                        cpk->valid_flags = rv;