]> git.kaiwu.me - nginx.git/commitdiff
ngx_ssl_recv_chain() must not update buf->last,
authorIgor Sysoev <igor@sysoev.ru>
Sat, 31 Mar 2007 19:48:48 +0000 (19:48 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Sat, 31 Mar 2007 19:48:48 +0000 (19:48 +0000)
it fixes proxy_pass https://...

src/event/ngx_event_openssl.c

index f8af57e38818e2427b6f3612fe8e7766bb428c92..5bd3b6a16bd22f92c396b8aae4426d54255d828c 100644 (file)
@@ -547,22 +547,32 @@ ngx_ssl_handshake_handler(ngx_event_t *ev)
 ssize_t
 ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl)
 {
+    u_char     *last;
     ssize_t     n, bytes;
     ngx_buf_t  *b;
 
     bytes = 0;
 
-    while (cl) {
-        b = cl->buf;
+    b = cl->buf;
+    last = b->last;
 
-        n = ngx_ssl_recv(c, b->last, b->end - b->last);
+    for ( ;; ) {
+
+        n = ngx_ssl_recv(c, last, b->end - last);
 
         if (n > 0) {
-            b->last += n;
+            last += n;
             bytes += n;
 
-            if (b->last == b->end) {
+            if (last == b->end) {
                 cl = cl->next;
+
+                if (cl == NULL) {
+                    return bytes;
+                }
+
+                b = cl->buf;
+                last = b->last;
             }
 
             continue;
@@ -574,8 +584,6 @@ ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl)
 
         return n;
     }
-
-    return bytes;
 }