Assorted bugfixes:
[openssl.git] / ssl / s2_srvr.c
index f0a1d4c3a94795246cebd6565aa079ad13433c59..bc885e8e7f6dbc440001b025d8a3315df759152b 100644 (file)
@@ -144,7 +144,7 @@ IMPLEMENT_ssl2_meth_func(SSLv2_server_method,
 
 int ssl2_accept(SSL *s)
        {
-       unsigned long l=time(NULL);
+       unsigned long l=(unsigned long)time(NULL);
        BUF_MEM *buf=NULL;
        int ret= -1;
        long num1;
@@ -267,7 +267,7 @@ int ssl2_accept(SSL *s)
                case SSL2_ST_SEND_SERVER_VERIFY_C:
                        /* get the number of bytes to write */
                        num1=BIO_ctrl(s->wbio,BIO_CTRL_INFO,0,NULL);
-                       if (num1 != 0)
+                       if (num1 > 0)
                                {
                                s->rwstate=SSL_WRITING;
                                num1=BIO_flush(s->wbio);
@@ -366,7 +366,7 @@ static int get_client_master_key(SSL *s)
        int is_export,i,n,keya,ek;
        unsigned long len;
        unsigned char *p;
-       SSL_CIPHER *cp;
+       const SSL_CIPHER *cp;
        const EVP_CIPHER *c;
        const EVP_MD *md;
 
@@ -403,13 +403,14 @@ static int get_client_master_key(SSL *s)
                p+=3;
                n2s(p,i); s->s2->tmp.clear=i;
                n2s(p,i); s->s2->tmp.enc=i;
-               n2s(p,i); s->session->key_arg_length=i;
-               if(s->session->key_arg_length > SSL_MAX_KEY_ARG_LENGTH)
+               n2s(p,i);
+               if(i > SSL_MAX_KEY_ARG_LENGTH)
                        {
                        ssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);
                        SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_KEY_ARG_TOO_LONG);
                        return -1;
                        }
+               s->session->key_arg_length=i;
                s->state=SSL2_ST_GET_CLIENT_MASTER_KEY_B;
                }
 
@@ -451,7 +452,7 @@ static int get_client_master_key(SSL *s)
 
        is_export=SSL_C_IS_EXPORT(s->session->cipher);
        
-       if (!ssl_cipher_get_evp(s->session,&c,&md,NULL))
+       if (!ssl_cipher_get_evp(s->session,&c,&md,NULL,NULL,NULL))
                {
                ssl2_return_error(s,SSL2_PE_NO_CIPHER);
                SSLerr(SSL_F_GET_CLIENT_MASTER_KEY,SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS);
@@ -607,7 +608,7 @@ static int get_client_hello(SSL *s)
        else
                {
                i=ssl_get_prev_session(s,&(p[s->s2->tmp.cipher_spec_length]),
-                       s->s2->tmp.session_id_length);
+                       s->s2->tmp.session_id_length, NULL);
                if (i == 1)
                        { /* previous session */
                        s->hit=1;
@@ -657,7 +658,7 @@ static int get_client_hello(SSL *s)
                        {
                        if (sk_SSL_CIPHER_find(allow,sk_SSL_CIPHER_value(prio,z)) < 0)
                                {
-                               sk_SSL_CIPHER_delete(prio,z);
+                               (void)sk_SSL_CIPHER_delete(prio,z);
                                z--;
                                }
                        }
@@ -697,7 +698,6 @@ static int server_hello(SSL *s)
        {
        unsigned char *p,*d;
        int n,hit;
-       STACK_OF(SSL_CIPHER) *sk;
 
        p=(unsigned char *)s->init_buf->data;
        if (s->state == SSL2_ST_SEND_SERVER_HELLO_A)
@@ -778,7 +778,6 @@ static int server_hello(SSL *s)
                        
                        /* lets send out the ciphers we like in the
                         * prefered order */
-                       sk= s->session->ciphers;
                        n=ssl_cipher_list_to_bytes(s,s->session->ciphers,d,0);
                        d+=n;
                        s2n(n,p);               /* add cipher length */
@@ -1054,7 +1053,7 @@ static int request_certificate(SSL *s)
 
        i=ssl_verify_cert_chain(s,sk);
 
-       if (i)  /* we like the packet, now check the chksum */
+       if (i > 0)      /* we like the packet, now check the chksum */
                {
                EVP_MD_CTX ctx;
                EVP_PKEY *pkey=NULL;
@@ -1083,7 +1082,7 @@ static int request_certificate(SSL *s)
                EVP_PKEY_free(pkey);
                EVP_MD_CTX_cleanup(&ctx);
 
-               if (i
+               if (i > 0)
                        {
                        if (s->session->peer != NULL)
                                X509_free(s->session->peer);