提交 0647719d 编写于 作者: M Matt Caswell

Make the checks for an SSLv2 style record stricter

SSLv2 is no longer supported in 1.1.0, however we *do* still accept an SSLv2
style ClientHello, as long as we then subsequently negotiate a protocol
version >= SSLv3. The record format for SSLv2 style ClientHellos is quite
different to SSLv3+. We only accept this format in the first record of an
initial ClientHello. Previously we checked this by confirming
s->first_packet is set and s->server is true. However, this really only
tells us that we are dealing with an initial ClientHello, not that it is
the first record (s->first_packet is badly named...it really means this is
the first message). To check this is the first record of the initial
ClientHello we should also check that we've not received any data yet
(s->init_num == 0), and that we've not had any empty records.

GitHub Issue #1298
Reviewed-by: NEmilia Käsper <emilia@openssl.org>
上级 1a627771
......@@ -160,12 +160,18 @@ int ssl3_get_record(SSL *s)
/*
* Check whether this is a regular record or an SSLv2 style record.
* The latter is only used in an initial ClientHello for old
* clients. We check s->read_hash and s->enc_read_ctx to ensure this
* does not apply during renegotiation
* The latter can only be used in the first record of an initial
* ClientHello for old clients. Initial ClientHello means
* s->first_packet is set and s->server is true. The first record
* means we've not received any data so far (s->init_num == 0) and
* have had no empty records. We check s->read_hash and
* s->enc_read_ctx to ensure this does not apply during
* renegotiation.
*/
if (s->first_packet && s->server && !s->read_hash
&& !s->enc_read_ctx
if (s->first_packet && s->server
&& s->init_num == 0
&& RECORD_LAYER_get_empty_record_count(&s->rlayer) == 0
&& s->read_hash == NULL && s->enc_read_ctx == NULL
&& (p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) {
/*
* SSLv2 style record
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册