aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2012-05-11 13:14:58 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2012-05-11 13:14:58 +0000
commit9114f08863cd6dd8a523a843fcf9be2a4518d60b (patch)
treeae34dc22f0714046f770f98c836b600d790f6054 /src
parentb34f84d8de0d834f26253579491f081bcb441a64 (diff)
downloadnginx-9114f08863cd6dd8a523a843fcf9be2a4518d60b.tar.gz
nginx-9114f08863cd6dd8a523a843fcf9be2a4518d60b.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 65f0747a1..55c3aef29 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -1356,7 +1356,11 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
}
} 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,7 +1693,12 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
}
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 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
}
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 @@ ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
}
} 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;