Mercurial > hg > nginx-quic
diff src/event/ngx_event_openssl.c @ 5882:ec81934727a1
Core: added limit to recv_chain().
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Tue, 28 Oct 2014 12:29:58 +0300 |
parents | ca63fc5ed9b1 |
children | 42520df85ebb |
line wrap: on
line diff
--- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -1185,10 +1185,10 @@ ngx_ssl_handshake_handler(ngx_event_t *e ssize_t -ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl) +ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit) { u_char *last; - ssize_t n, bytes; + ssize_t n, bytes, size; ngx_buf_t *b; bytes = 0; @@ -1197,8 +1197,19 @@ ngx_ssl_recv_chain(ngx_connection_t *c, last = b->last; for ( ;; ) { - - n = ngx_ssl_recv(c, last, b->end - last); + size = b->end - last; + + if (limit) { + if (bytes >= limit) { + return bytes; + } + + if (bytes + size > limit) { + size = (ssize_t) (limit - bytes); + } + } + + n = ngx_ssl_recv(c, last, size); if (n > 0) { last += n;