Update to OpenSSL 1.0.2.o
This commit is contained in:
51
ssl/s3_pkt.c
51
ssl/s3_pkt.c
@@ -56,7 +56,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -670,7 +670,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
|
||||
* promptly send beyond the end of the users buffer ... so we trap and
|
||||
* report the error in a way the user will notice
|
||||
*/
|
||||
if (len < tot) {
|
||||
if ((len < tot) || ((wb->left != 0) && (len < (tot + s->s3->wpend_tot)))) {
|
||||
SSLerr(SSL_F_SSL3_WRITE_BYTES, SSL_R_BAD_LENGTH);
|
||||
return (-1);
|
||||
}
|
||||
@@ -699,6 +699,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
|
||||
len >= 4 * (int)(max_send_fragment = s->max_send_fragment) &&
|
||||
s->compress == NULL && s->msg_callback == NULL &&
|
||||
SSL_USE_EXPLICIT_IV(s) &&
|
||||
s->enc_write_ctx != NULL &&
|
||||
EVP_CIPHER_flags(s->enc_write_ctx->cipher) &
|
||||
EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK) {
|
||||
unsigned char aad[13];
|
||||
@@ -1095,10 +1096,9 @@ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
|
||||
int i;
|
||||
SSL3_BUFFER *wb = &(s->s3->wbuf);
|
||||
|
||||
/* XXXX */
|
||||
if ((s->s3->wpend_tot > (int)len)
|
||||
|| ((s->s3->wpend_buf != buf) &&
|
||||
!(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER))
|
||||
|| (!(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)
|
||||
&& (s->s3->wpend_buf != buf))
|
||||
|| (s->s3->wpend_type != type)) {
|
||||
SSLerr(SSL_F_SSL3_WRITE_PENDING, SSL_R_BAD_WRITE_RETRY);
|
||||
return (-1);
|
||||
@@ -1313,20 +1313,26 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
|
||||
unsigned int *dest_len = NULL;
|
||||
|
||||
if (rr->type == SSL3_RT_HANDSHAKE) {
|
||||
dest_maxlen = sizeof s->s3->handshake_fragment;
|
||||
dest_maxlen = sizeof(s->s3->handshake_fragment);
|
||||
dest = s->s3->handshake_fragment;
|
||||
dest_len = &s->s3->handshake_fragment_len;
|
||||
} else if (rr->type == SSL3_RT_ALERT) {
|
||||
dest_maxlen = sizeof s->s3->alert_fragment;
|
||||
dest_maxlen = sizeof(s->s3->alert_fragment);
|
||||
dest = s->s3->alert_fragment;
|
||||
dest_len = &s->s3->alert_fragment_len;
|
||||
}
|
||||
#ifndef OPENSSL_NO_HEARTBEATS
|
||||
else if (rr->type == TLS1_RT_HEARTBEAT) {
|
||||
tls1_process_heartbeat(s);
|
||||
i = tls1_process_heartbeat(s);
|
||||
|
||||
if (i < 0)
|
||||
return i;
|
||||
|
||||
rr->length = 0;
|
||||
if (s->mode & SSL_MODE_AUTO_RETRY)
|
||||
goto start;
|
||||
|
||||
/* Exit and notify application to read again */
|
||||
rr->length = 0;
|
||||
s->rwstate = SSL_READING;
|
||||
BIO_clear_retry_flags(SSL_get_rbio(s));
|
||||
BIO_set_retry_read(SSL_get_rbio(s));
|
||||
@@ -1414,26 +1420,25 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
|
||||
*/
|
||||
goto start;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are a server and get a client hello when renegotiation isn't
|
||||
* allowed send back a no renegotiation alert and carry on. WARNING:
|
||||
* experimental code, needs reviewing (steve)
|
||||
* allowed send back a no renegotiation alert and carry on.
|
||||
*/
|
||||
if (s->server &&
|
||||
SSL_is_init_finished(s) &&
|
||||
!s->s3->send_connection_binding &&
|
||||
(s->version > SSL3_VERSION) &&
|
||||
(s->s3->handshake_fragment_len >= 4) &&
|
||||
(s->s3->handshake_fragment[0] == SSL3_MT_CLIENT_HELLO) &&
|
||||
(s->session != NULL) && (s->session->cipher != NULL) &&
|
||||
!(s->ctx->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {
|
||||
/*
|
||||
* s->s3->handshake_fragment_len = 0;
|
||||
*/
|
||||
if (s->server
|
||||
&& SSL_is_init_finished(s)
|
||||
&& !s->s3->send_connection_binding
|
||||
&& s->version > SSL3_VERSION
|
||||
&& s->s3->handshake_fragment_len >= SSL3_HM_HEADER_LENGTH
|
||||
&& s->s3->handshake_fragment[0] == SSL3_MT_CLIENT_HELLO
|
||||
&& s->s3->previous_client_finished_len != 0
|
||||
&& (s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION) == 0) {
|
||||
s->s3->handshake_fragment_len = 0;
|
||||
rr->length = 0;
|
||||
ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_NO_RENEGOTIATION);
|
||||
goto start;
|
||||
}
|
||||
|
||||
if (s->s3->alert_fragment_len >= 2) {
|
||||
int alert_level = s->s3->alert_fragment[0];
|
||||
int alert_descr = s->s3->alert_fragment[1];
|
||||
@@ -1491,7 +1496,7 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
|
||||
s->rwstate = SSL_NOTHING;
|
||||
s->s3->fatal_alert = alert_descr;
|
||||
SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr);
|
||||
BIO_snprintf(tmp, sizeof tmp, "%d", alert_descr);
|
||||
BIO_snprintf(tmp, sizeof(tmp), "%d", alert_descr);
|
||||
ERR_add_error_data(2, "SSL alert number ", tmp);
|
||||
s->shutdown |= SSL_RECEIVED_SHUTDOWN;
|
||||
SSL_CTX_remove_session(s->session_ctx, s->session);
|
||||
|
||||
Reference in New Issue
Block a user