[nginx] svn commit: r4617 - trunk/src/http/modules

mdounin at mdounin.ru mdounin at mdounin.ru
Fri May 11 13:14:59 UTC 2012


Author: mdounin
Date: 2012-05-11 13:14:58 +0000 (Fri, 11 May 2012)
New Revision: 4617
URL: http://trac.nginx.org/nginx/changeset/4617/nginx

Log:
Fastcgi: fixed padding handling on fixed-size records.

Padding was incorrectly ignored on end request, empty stdout and stderr
fastcgi records.  This resulted in protocol desynchronization if fastcgi
application used these records with padding for some reason.

Reported by Ilia Vinokurov.


Modified:
   trunk/src/http/modules/ngx_http_fastcgi_module.c

Modified: trunk/src/http/modules/ngx_http_fastcgi_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_fastcgi_module.c	2012-05-11 13:09:24 UTC (rev 4616)
+++ trunk/src/http/modules/ngx_http_fastcgi_module.c	2012-05-11 13:14:58 UTC (rev 4617)
@@ -1356,7 +1356,11 @@
                 }
 
             } else {
-                f->state = ngx_http_fastcgi_st_version;
+                if (f->padding) {
+                    f->state = ngx_http_fastcgi_st_padding;
+                } else {
+                    f->state = ngx_http_fastcgi_st_version;
+                }
             }
 
             continue;
@@ -1689,8 +1693,13 @@
             }
 
             if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) {
-                f->state = ngx_http_fastcgi_st_version;
 
+                if (f->padding) {
+                    f->state = ngx_http_fastcgi_st_padding;
+                } else {
+                    f->state = ngx_http_fastcgi_st_version;
+                }
+
                 if (!flcf->keep_conn) {
                     p->upstream_done = 1;
                 }
@@ -1702,7 +1711,13 @@
             }
 
             if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) {
-                f->state = ngx_http_fastcgi_st_version;
+
+                if (f->padding) {
+                    f->state = ngx_http_fastcgi_st_padding;
+                } else {
+                    f->state = ngx_http_fastcgi_st_version;
+                }
+
                 p->upstream_done = 1;
 
                 if (flcf->keep_conn) {
@@ -1775,7 +1790,11 @@
                 }
 
             } else {
-                f->state = ngx_http_fastcgi_st_version;
+                if (f->padding) {
+                    f->state = ngx_http_fastcgi_st_padding;
+                } else {
+                    f->state = ngx_http_fastcgi_st_version;
+                }
             }
 
             continue;



More information about the nginx-devel mailing list