diff options
author | jkim <jkim@FreeBSD.org> | 2014-10-15 19:12:05 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2014-10-15 19:12:05 +0000 |
commit | 411d431d45a87a859fd5507449dc4529d6ee1c08 (patch) | |
tree | c23fa858f36ae42eb7fe9898b481a136f3f8733b /crypto/openssl/ssl/s3_pkt.c | |
parent | cfb0e0275efcad3cdfca0ae280949467ed709e9f (diff) | |
parent | 9a02b27a6e11c9667427250a26589d17ad31e847 (diff) | |
download | FreeBSD-src-411d431d45a87a859fd5507449dc4529d6ee1c08.zip FreeBSD-src-411d431d45a87a859fd5507449dc4529d6ee1c08.tar.gz |
Merge OpenSSL 1.0.1j.
Diffstat (limited to 'crypto/openssl/ssl/s3_pkt.c')
-rw-r--r-- | crypto/openssl/ssl/s3_pkt.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/crypto/openssl/ssl/s3_pkt.c b/crypto/openssl/ssl/s3_pkt.c index eff7356..4c9285f 100644 --- a/crypto/openssl/ssl/s3_pkt.c +++ b/crypto/openssl/ssl/s3_pkt.c @@ -273,6 +273,12 @@ int ssl3_read_n(SSL *s, int n, int max, int extend) return(n); } +/* MAX_EMPTY_RECORDS defines the number of consecutive, empty records that will + * be processed per call to ssl3_get_record. Without this limit an attacker + * could send empty records at a faster rate than we can process and cause + * ssl3_get_record to loop forever. */ +#define MAX_EMPTY_RECORDS 32 + /* Call this to get a new input record. * It will return <= 0 if more data is needed, normally due to an error * or non-blocking IO. @@ -293,6 +299,7 @@ static int ssl3_get_record(SSL *s) short version; unsigned mac_size, orig_len; size_t extra; + unsigned empty_record_count = 0; rr= &(s->s3->rrec); sess=s->session; @@ -523,7 +530,17 @@ printf("\n"); s->packet_length=0; /* just read a 0 length packet */ - if (rr->length == 0) goto again; + if (rr->length == 0) + { + empty_record_count++; + if (empty_record_count > MAX_EMPTY_RECORDS) + { + al=SSL_AD_UNEXPECTED_MESSAGE; + SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_RECORD_TOO_SMALL); + goto f_err; + } + goto again; + } #if 0 fprintf(stderr, "Ultimate Record type=%d, Length=%d\n", rr->type, rr->length); |