diff --git a/crypto/external/bsd/openssl/dist/ssl/d1_enc.c b/crypto/external/bsd/openssl/dist/ssl/d1_enc.c index becbab91c219..07a5e97ce5cd 100644 --- a/crypto/external/bsd/openssl/dist/ssl/d1_enc.c +++ b/crypto/external/bsd/openssl/dist/ssl/d1_enc.c @@ -260,7 +260,7 @@ int dtls1_enc(SSL *s, int send) } /* TLS 1.0 does not bound the number of padding bytes by the block size. * All of them must have value 'padding_length'. */ - if (i > (int)rec->length) + if (i + bs > (int)rec->length) { /* Incorrect padding. SSLerr() and ssl3_alert are done * by caller: we don't want to reveal whether this is diff --git a/crypto/external/bsd/openssl/dist/ssl/t1_enc.c b/crypto/external/bsd/openssl/dist/ssl/t1_enc.c index 58c5c6a27ba6..aad74f036108 100644 --- a/crypto/external/bsd/openssl/dist/ssl/t1_enc.c +++ b/crypto/external/bsd/openssl/dist/ssl/t1_enc.c @@ -823,6 +823,8 @@ int tls1_enc(SSL *s, int send) if (s->version >= TLS1_1_VERSION && EVP_CIPHER_CTX_mode(ds) == EVP_CIPH_CBC_MODE) { + if (bs > (int)rec->length) + return -1; rec->data += bs; /* skip the explicit IV */ rec->input += bs; rec->length -= bs;