From 1f48fba861901389b9e7ab1b3f569af30f25c4d5 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Sat, 13 Dec 2014 01:33:12 -0500 Subject: [PATCH] Use have_version in clamping TLS record-layer version to 1.0. Match the DTLS code. Rather than sniffing the handshake state, use the have_version bit. Change-Id: I40e92f187647417c34b4cfdc3ad258f5562e781b Reviewed-on: https://boringssl-review.googlesource.com/2588 Reviewed-by: Adam Langley --- ssl/s3_pkt.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c index e3c93934..e980cdc8 100644 --- a/ssl/s3_pkt.c +++ b/ssl/s3_pkt.c @@ -736,16 +736,18 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, *(p++)=type&0xff; wr->type=type; - *(p++)=(s->version>>8); - /* Some servers hang if iniatial client hello is larger than 256 - * bytes and record version number > TLS 1.0 - */ - if (s->state == SSL3_ST_CW_CLNT_HELLO_B - && !s->renegotiate - && TLS1_get_version(s) > TLS1_VERSION) - *(p++) = 0x1; + /* Some servers hang if initial ClientHello is larger than 256 + * bytes and record version number > TLS 1.0. */ + if (!s->s3->have_version && s->version > SSL3_VERSION) + { + *(p++) = TLS1_VERSION >> 8; + *(p++) = TLS1_VERSION & 0xff; + } else - *(p++)=s->version&0xff; + { + *(p++) = s->version >> 8; + *(p++) = s->version & 0xff; + } /* field where we are to write out packet length */ plen=p;