diff options
author | jkim <jkim@FreeBSD.org> | 2015-06-11 19:00:55 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2015-06-11 19:00:55 +0000 |
commit | d675e841ef78a78bab5972d63fa3d8d15ecdbb19 (patch) | |
tree | af421c8f5f156e1b4b26149d5c4964d037dd0454 /crypto/openssl/ssl/s2_pkt.c | |
parent | aec7d82113b7de83f7ac3f9470fde49813358dec (diff) | |
download | FreeBSD-src-d675e841ef78a78bab5972d63fa3d8d15ecdbb19.zip FreeBSD-src-d675e841ef78a78bab5972d63fa3d8d15ecdbb19.tar.gz |
Merge OpenSSL 1.0.1n.
Diffstat (limited to 'crypto/openssl/ssl/s2_pkt.c')
-rw-r--r-- | crypto/openssl/ssl/s2_pkt.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/openssl/ssl/s2_pkt.c b/crypto/openssl/ssl/s2_pkt.c index 614b9a3..7a61888 100644 --- a/crypto/openssl/ssl/s2_pkt.c +++ b/crypto/openssl/ssl/s2_pkt.c @@ -576,6 +576,20 @@ static int n_do_ssl_write(SSL *s, const unsigned char *buf, unsigned int len) s->s2->padding = p; s->s2->mac_data = &(s->s2->wbuf[3]); s->s2->wact_data = &(s->s2->wbuf[3 + mac_size]); + + /* + * It would be clearer to write this as follows: + * if (mac_size + len + p > SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER) + * However |len| is user input that could in theory be very large. We + * know |mac_size| and |p| are small, so to avoid any possibility of + * overflow we write it like this. + * + * In theory this should never fail because the logic above should have + * modified |len| if it is too big. But we are being cautious. + */ + if (len > (SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER - (mac_size + p))) { + return -1; + } /* we copy the data into s->s2->wbuf */ memcpy(s->s2->wact_data, buf, len); if (p) |