diff src/os/unix/ngx_darwin_sendfile_chain.c @ 672:f41d4b305d22 NGINX_1_2_0

nginx 1.2.0 *) Bugfix: a segmentation fault might occur in a worker process if the "try_files" directive was used; the bug had appeared in 1.1.19. *) Bugfix: response might be truncated if there were more than IOV_MAX buffers used. *) Bugfix: in the "crop" parameter of the "image_filter" directive. Thanks to Maxim Bublis.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Apr 2012 00:00:00 +0400
parents f5b859b2f097
children
line wrap: on
line diff
--- a/src/os/unix/ngx_darwin_sendfile_chain.c
+++ b/src/os/unix/ngx_darwin_sendfile_chain.c
@@ -103,10 +103,8 @@ ngx_darwin_sendfile_chain(ngx_connection
         prev = NULL;
         iov = NULL;
 
-        for (cl = in;
-             cl && header.nelts < IOV_MAX && send < limit;
-             cl = cl->next)
-        {
+        for (cl = in; cl && send < limit; cl = cl->next) {
+
             if (ngx_buf_special(cl->buf)) {
                 continue;
             }
@@ -125,6 +123,10 @@ ngx_darwin_sendfile_chain(ngx_connection
                 iov->iov_len += (size_t) size;
 
             } else {
+                if (header.nelts >= IOV_MAX) {
+                    break;
+                }
+
                 iov = ngx_array_push(&header);
                 if (iov == NULL) {
                     return NGX_CHAIN_ERROR;
@@ -178,7 +180,7 @@ ngx_darwin_sendfile_chain(ngx_connection
             prev = NULL;
             iov = NULL;
 
-            while (cl && header.nelts < IOV_MAX && send < limit) {
+            while (cl && send < limit) {
 
                 if (ngx_buf_special(cl->buf)) {
                     cl = cl->next;
@@ -199,6 +201,10 @@ ngx_darwin_sendfile_chain(ngx_connection
                     iov->iov_len += (size_t) size;
 
                 } else {
+                    if (trailer.nelts >= IOV_MAX) {
+                        break;
+                    }
+
                     iov = ngx_array_push(&trailer);
                     if (iov == NULL) {
                         return NGX_CHAIN_ERROR;