Don't change version number if session established
authorDr. Stephen Henson <steve@openssl.org>
Tue, 24 Dec 2013 18:17:00 +0000 (18:17 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 2 Jan 2014 15:12:48 +0000 (15:12 +0000)
When sending an invalid version number alert don't change the
version number to the client version if a session is already
established.

Thanks to Marek Majkowski for additional analysis of this issue.

PR#3191

ssl/s3_pkt.c
ssl/s3_srvr.c

index c4bc4e787da079a0f05eceb2705c1f2bcb9cd956..96ba63262e44e67dc405935cb0c3c5ed0e1f6d6f 100644 (file)
@@ -335,7 +335,7 @@ fprintf(stderr, "Record type=%d, Length=%d\n", rr->type, rr->length);
                        if (version != s->version)
                                {
                                SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_WRONG_VERSION_NUMBER);
-                                if ((s->version & 0xFF00) == (version & 0xFF00))
+                                if ((s->version & 0xFF00) == (version & 0xFF00) && !s->enc_write_ctx && !s->write_hash)
                                        /* Send back error using their minor version number :-) */
                                        s->version = (unsigned short)version;
                                al=SSL_AD_PROTOCOL_VERSION;
index e5a8b3fbf27ad171468a2680fd7929502f04c2b4..52efed328a14ed4bdc2343d23dc9d2d3775160ae 100644 (file)
@@ -958,7 +958,8 @@ int ssl3_get_client_hello(SSL *s)
            (s->version != DTLS1_VERSION && s->client_version < s->version))
                {
                SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER);
-               if ((s->client_version>>8) == SSL3_VERSION_MAJOR)
+               if ((s->client_version>>8) == SSL3_VERSION_MAJOR && 
+                       !s->enc_write_ctx && !s->write_hash)
                        {
                        /* similar to ssl3_get_record, send alert using remote version number */
                        s->version = s->client_version;