|
|
653b37 |
diff -up openssl-1.0.1e/ssl/d1_both.c.certmsg-len openssl-1.0.1e/ssl/d1_both.c
|
|
|
653b37 |
--- openssl-1.0.1e/ssl/d1_both.c.certmsg-len 2016-09-20 16:12:01.000000000 +0200
|
|
|
653b37 |
+++ openssl-1.0.1e/ssl/d1_both.c 2016-09-22 11:02:54.277707284 +0200
|
|
|
653b37 |
@@ -506,8 +506,11 @@ static int dtls1_preprocess_fragment(SSL
|
|
|
653b37 |
if ( s->d1->r_msg_hdr.frag_off == 0) /* first fragment */
|
|
|
653b37 |
{
|
|
|
653b37 |
/* msg_len is limited to 2^24, but is effectively checked
|
|
|
653b37 |
- * against max above */
|
|
|
653b37 |
- if (!BUF_MEM_grow_clean(s->init_buf,msg_len+DTLS1_HM_HEADER_LENGTH))
|
|
|
653b37 |
+ * against max above
|
|
|
653b37 |
+ *
|
|
|
653b37 |
+ * Make buffer slightly larger than message length as
|
|
|
653b37 |
+ * a precaution against small OOB reads e.g. CVE-2016-6306 */
|
|
|
653b37 |
+ if (!BUF_MEM_grow_clean(s->init_buf,msg_len+DTLS1_HM_HEADER_LENGTH+16))
|
|
|
653b37 |
{
|
|
|
653b37 |
SSLerr(SSL_F_DTLS1_PREPROCESS_FRAGMENT,ERR_R_BUF_LIB);
|
|
|
653b37 |
return SSL_AD_INTERNAL_ERROR;
|
|
|
653b37 |
diff -up openssl-1.0.1e/ssl/s3_both.c.certmsg-len openssl-1.0.1e/ssl/s3_both.c
|
|
|
653b37 |
--- openssl-1.0.1e/ssl/s3_both.c.certmsg-len 2016-09-20 14:55:57.000000000 +0200
|
|
|
653b37 |
+++ openssl-1.0.1e/ssl/s3_both.c 2016-09-22 11:06:00.945725379 +0200
|
|
|
653b37 |
@@ -518,7 +518,11 @@ long ssl3_get_message(SSL *s, int st1, i
|
|
|
653b37 |
SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);
|
|
|
653b37 |
goto f_err;
|
|
|
653b37 |
}
|
|
|
653b37 |
- if (l && !BUF_MEM_grow_clean(s->init_buf,(int)l+4))
|
|
|
653b37 |
+ /*
|
|
|
653b37 |
+ * Make buffer slightly larger than message length as a precaution
|
|
|
653b37 |
+ * against small OOB reads e.g. CVE-2016-6306
|
|
|
653b37 |
+ */
|
|
|
653b37 |
+ if (l && !BUF_MEM_grow_clean(s->init_buf,(int)l+4+16))
|
|
|
653b37 |
{
|
|
|
653b37 |
SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB);
|
|
|
653b37 |
goto err;
|
|
|
653b37 |
diff -up openssl-1.0.1e/ssl/s3_clnt.c.certmsg-len openssl-1.0.1e/ssl/s3_clnt.c
|
|
|
653b37 |
--- openssl-1.0.1e/ssl/s3_clnt.c.certmsg-len 2016-09-20 14:55:57.000000000 +0200
|
|
|
653b37 |
+++ openssl-1.0.1e/ssl/s3_clnt.c 2016-09-20 18:27:22.683077436 +0200
|
|
|
653b37 |
@@ -1128,6 +1128,12 @@ int ssl3_get_server_certificate(SSL *s)
|
|
|
653b37 |
}
|
|
|
653b37 |
for (nc=0; nc
|
|
|
653b37 |
{
|
|
|
653b37 |
+ if (nc+3 > llen)
|
|
|
653b37 |
+ {
|
|
|
653b37 |
+ al = SSL_AD_DECODE_ERROR;
|
|
|
653b37 |
+ SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERT_LENGTH_MISMATCH);
|
|
|
653b37 |
+ goto f_err;
|
|
|
653b37 |
+ }
|
|
|
653b37 |
n2l3(p,l);
|
|
|
653b37 |
if ((l+nc+3) > llen)
|
|
|
653b37 |
{
|
|
|
653b37 |
@@ -1979,6 +1985,12 @@ fclose(out);
|
|
|
653b37 |
|
|
|
653b37 |
for (nc=0; nc
|
|
|
653b37 |
{
|
|
|
653b37 |
+ if (nc+2 > llen)
|
|
|
653b37 |
+ {
|
|
|
653b37 |
+ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
|
|
653b37 |
+ SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST, SSL_R_CA_DN_TOO_LONG);
|
|
|
653b37 |
+ goto err;
|
|
|
653b37 |
+ }
|
|
|
653b37 |
n2s(p,l);
|
|
|
653b37 |
if ((l+nc+2) > llen)
|
|
|
653b37 |
{
|
|
|
653b37 |
diff -up openssl-1.0.1e/ssl/s3_srvr.c.certmsg-len openssl-1.0.1e/ssl/s3_srvr.c
|
|
|
653b37 |
--- openssl-1.0.1e/ssl/s3_srvr.c.certmsg-len 2016-09-20 15:14:11.000000000 +0200
|
|
|
653b37 |
+++ openssl-1.0.1e/ssl/s3_srvr.c 2016-09-20 18:29:26.167950476 +0200
|
|
|
653b37 |
@@ -3269,6 +3269,12 @@ int ssl3_get_client_certificate(SSL *s)
|
|
|
653b37 |
}
|
|
|
653b37 |
for (nc=0; nc
|
|
|
653b37 |
{
|
|
|
653b37 |
+ if (nc+3 > llen)
|
|
|
653b37 |
+ {
|
|
|
653b37 |
+ al = SSL_AD_DECODE_ERROR;
|
|
|
653b37 |
+ SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_CERT_LENGTH_MISMATCH);
|
|
|
653b37 |
+ goto f_err;
|
|
|
653b37 |
+ }
|
|
|
653b37 |
n2l3(p,l);
|
|
|
653b37 |
if ((l+nc+3) > llen)
|
|
|
653b37 |
{
|