Fix SSLv2-compatible ClientHello processing.
authorEmilia Kasper <emilia@openssl.org>
Tue, 18 Aug 2015 17:01:51 +0000 (19:01 +0200)
committerEmilia Kasper <emilia@openssl.org>
Wed, 26 Aug 2015 11:23:24 +0000 (13:23 +0200)
If the client challenge is less than 32 bytes, it is padded with leading - not trailing - zero bytes.

Reviewed-by: Matt Caswell <matt@openssl.org>
ssl/s3_srvr.c

index 8bdb082..2d15c63 100644 (file)
@@ -1057,7 +1057,9 @@ int ssl3_get_client_hello(SSL *s)
         /* Load the client random */
         i = (cl > SSL3_RANDOM_SIZE) ? SSL3_RANDOM_SIZE : cl;
         memset(s->s3->client_random, 0, SSL3_RANDOM_SIZE);
-        if (!PACKET_peek_copy_bytes(&pkt, s->s3->client_random, i)
+        if (!PACKET_peek_copy_bytes(&pkt,
+                                    s->s3->client_random + SSL3_RANDOM_SIZE - i,
+                                    i)
                 || !PACKET_forward(&pkt, cl)
                 || PACKET_remaining(&pkt) != 0) {
             SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_RECORD_LENGTH_MISMATCH);