Check i before r[i].
authorDr. Stephen Henson <steve@openssl.org>
Tue, 28 Jan 2014 15:10:27 +0000 (15:10 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 28 Jan 2014 15:14:47 +0000 (15:14 +0000)
PR#3244
(cherry picked from commit 9614d2c676ffe74ce0c919d9e5c0d622a011cbed)

ssl/s3_srvr.c

index 8e8daf2997fc0ee356ad4dedb9df03d53640597a..8902303afda6c8e46c0926683a76f05dbe97e3bd 100644 (file)
@@ -1878,7 +1878,7 @@ int ssl3_send_server_key_exchange(SSL *s)
                        SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE);
                        goto f_err;
                        }
-               for (i=0; r[i] != NULL && i<4; i++)
+               for (i=0; i < 4 && r[i] != NULL; i++)
                        {
                        nr[i]=BN_num_bytes(r[i]);
 #ifndef OPENSSL_NO_SRP
@@ -1913,7 +1913,7 @@ int ssl3_send_server_key_exchange(SSL *s)
                        }
                d = p = ssl_handshake_start(s);
 
-               for (i=0; r[i] != NULL && i<4; i++)
+               for (i=0; i < 4 && r[i] != NULL; i++)
                        {
 #ifndef OPENSSL_NO_SRP
                        if ((i == 2) && (type & SSL_kSRP))