Welcome! Log In Create A New Profile

Advanced

[nginx] FastCGI: adjust buffer position when parsing incomplete records.

Maxim Dounin
November 09, 2017 07:40AM
details: http://hg.nginx.org/nginx/rev/3b635e8fd499
branches:
changeset: 7152:3b635e8fd499
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Nov 09 15:35:20 2017 +0300
description:
FastCGI: adjust buffer position when parsing incomplete records.

Previously, nginx failed to move buffer position when parsing an incomplete
record header, and due to this wasn't be able to continue parsing once
remaining bytes of the record header were received.

This can affect response header parsing, potentially generating spurious errors
like "upstream sent unexpected FastCGI request id high byte: 1 while reading
response header from upstream". While this is very unlikely, since usually
record headers are written in a single buffer, this still can happen in real
life, for example, if a record header will be split across two TCP packets
and the second packet will be delayed.

This does not affect non-buffered response body proxying, due to "buf->pos =
buf->last;" at the start of the ngx_http_fastcgi_non_buffered_filter()
function. Also this does not affect buffered response body proxying, as
each input buffer is only passed to the filter once.

diffstat:

src/http/modules/ngx_http_fastcgi_module.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -2646,6 +2646,7 @@ ngx_http_fastcgi_process_record(ngx_http
}
}

+ f->pos = p;
f->state = state;

return NGX_AGAIN;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] FastCGI: adjust buffer position when parsing incomplete records.

Maxim Dounin 509 November 09, 2017 07:40AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 243
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready