Update from 1.0.0-stable.
authorDr. Stephen Henson <steve@openssl.org>
Fri, 5 Jun 2009 15:05:10 +0000 (15:05 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 5 Jun 2009 15:05:10 +0000 (15:05 +0000)
apps/s_server.c
crypto/bio/bss_dgram.c
ssl/d1_both.c
ssl/d1_clnt.c
ssl/d1_pkt.c
ssl/d1_srvr.c
ssl/dtls1.h

index 43f824b90d9f0301500c48acb00bb88df60d33fb..23d2217625a3176e5b570f47be1570e2123369a7 100644 (file)
@@ -284,7 +284,9 @@ static const char *session_id_prefix=NULL;
 
 static int enable_timeouts = 0;
 static long socket_mtu;
+#ifndef OPENSSL_NO_DTLS1
 static int cert_chain = 0;
+#endif
 
 
 #ifdef MONOLITH
index 2e1a6fac33d90596f1f812a0684c745b8f4d2c1e..027cdf943b7973b174f93b8325e48294dff0785f 100644 (file)
@@ -217,12 +217,19 @@ static void dgram_adjust_rcv_timeout(BIO *b)
                        timeleft.tv_usec += 1000000;
                        }
 
+               if (timeleft.tv_sec < 0)
+                       {
+                       timeleft.tv_sec = 0;
+                       timeleft.tv_usec = 1;
+                       }
+
                /* Adjust socket timeout if next handhake message timer
                 * will expire earlier.
                 */
-               if (data->socket_timeout.tv_sec < timeleft.tv_sec ||
+               if ((data->socket_timeout.tv_sec == 0 && data->socket_timeout.tv_usec == 0) ||
+                       (data->socket_timeout.tv_sec > timeleft.tv_sec) ||
                        (data->socket_timeout.tv_sec == timeleft.tv_sec &&
-                        data->socket_timeout.tv_usec <= timeleft.tv_usec))
+                        data->socket_timeout.tv_usec >= timeleft.tv_usec))
                        {
 #ifdef OPENSSL_SYS_WINDOWS
                        timeout = timeleft.tv_sec * 1000 + timeleft.tv_usec / 1000;
index fb74ed2763fd76ac10c76a2340e2cd272ed2cca2..69b6b10ba22e614304f6bf0031d072eda7247c6f 100644 (file)
@@ -568,9 +568,13 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok)
        pq_64bit_free(&seq64);
        
        /* Discard the message if sequence number was already there, is
-        * too far in the future or the fragment is already in the queue */
+        * too far in the future, already in the queue or if we received
+        * a FINISHED before the SERVER_HELLO, which then must be a stale
+        * retransmit.
+        */
        if (msg_hdr->seq <= s->d1->handshake_read_seq ||
-               msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL)
+               msg_hdr->seq > s->d1->handshake_read_seq + 10 || item != NULL ||
+               (s->d1->handshake_read_seq == 0 && msg_hdr->type == SSL3_MT_FINISHED))
                {
                unsigned char devnull [256];
 
index a95705448f4ea687aaf93053df57cf8b147f299b..20d6b7c404e12725456238aa7537bffc1b02f681 100644 (file)
@@ -440,7 +440,7 @@ int dtls1_connect(SSL *s)
 
                case SSL3_ST_CR_FINISHED_A:
                case SSL3_ST_CR_FINISHED_B:
-
+                       s->d1->change_cipher_spec_ok = 1;
                        ret=ssl3_get_finished(s,SSL3_ST_CR_FINISHED_A,
                                SSL3_ST_CR_FINISHED_B);
                        if (ret <= 0) goto end;
index ec7752d93a08b9a64b739c2e0aa2aade48803059..d88ef19fcde255831f0f5207c03fdf0446f8eb1c 100644 (file)
@@ -1058,6 +1058,16 @@ start:
                        s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, 
                                rr->data, 1, s, s->msg_callback_arg);
 
+               /* We can't process a CCS now, because previous handshake
+                * messages are still missing, so just drop it.
+                */
+               if (!s->d1->change_cipher_spec_ok)
+                       {
+                       goto start;
+                       }
+
+               s->d1->change_cipher_spec_ok = 0;
+
                s->s3->change_cipher_spec=1;
                if (!ssl3_do_change_cipher_spec(s))
                        goto err;
index 49671570b352df0ffdd9c9c4ec1168c055830dd6..992b6a742e2c2dc16fd26202e86b123fc3afd7e1 100644 (file)
@@ -470,6 +470,7 @@ int dtls1_accept(SSL *s)
                case SSL3_ST_SR_CERT_VRFY_A:
                case SSL3_ST_SR_CERT_VRFY_B:
 
+                       s->d1->change_cipher_spec_ok = 1;
                        /* we should decide if we expected this one */
                        ret=ssl3_get_cert_verify(s);
                        if (ret <= 0) goto end;
@@ -481,6 +482,7 @@ int dtls1_accept(SSL *s)
 
                case SSL3_ST_SR_FINISHED_A:
                case SSL3_ST_SR_FINISHED_B:
+                       s->d1->change_cipher_spec_ok = 1;
                        ret=ssl3_get_finished(s,SSL3_ST_SR_FINISHED_A,
                                SSL3_ST_SR_FINISHED_B);
                        if (ret <= 0) goto end;
index 091d7f0998a410786fbc6a7d1035781afa33b1fd..03774ec7e46b345592ba97664997c195ba7b5389 100644 (file)
@@ -229,6 +229,7 @@ typedef struct dtls1_state_st
        unsigned int handshake_fragment_len;
 
        unsigned int retransmitting;
+       unsigned int change_cipher_spec_ok;
 
        } DTLS1_STATE;