Welcome! Log In Create A New Profile

Advanced

[PATCH] ngx_http_parse_chunked might request wrong number of bytes

Dmitry Popov
June 27, 2013 03:22PM
Consider a case when we've just read chunk size (but nothing else):
case sw_chunk_size:
ctx->length = 2 /* LF LF */
+ (ctx->size ? ctx->size + 4 /* LF "0" LF LF */ : 0);
break;
ctx->length will be equal to 6 + ctx->size, but actually we need 5 + ctx->size
bytes: LF <data> LF 0 LF LF. It may lead to a deadlock (peer waits for a
response from us while we wait for that last byte).

* IIRC, RFC states that CRLF should be used after chunk size, not LF, so it's
not so critical, but I think it should be fixed anyway.

Signed-off-by: Dmitry Popov <dp@highloadlab.com>

diff -ur old/src/http/ngx_http_parse.c new/src/http/ngx_http_parse.c
--- old/src/http/ngx_http_parse.c 2013-06-04 17:21:53.000000000 +0400
+++ new/src/http/ngx_http_parse.c 2013-06-27 23:00:27.091638084 +0400
@@ -2180,8 +2180,10 @@
ctx->length = 3 /* "0" LF LF */;
break;
case sw_chunk_size:
- ctx->length = 2 /* LF LF */
- + (ctx->size ? ctx->size + 4 /* LF "0" LF LF */ : 0);
+ ctx->length = 1 /* LF */
+ + (ctx->size
+ ? ctx->size + 4 /* LF "0" LF LF */
+ : 1 /* LF */);
break;
case sw_chunk_extension:
case sw_chunk_extension_almost_done:

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

[PATCH] ngx_http_parse_chunked might request wrong number of bytes

Dmitry Popov 958 June 27, 2013 03:22PM

Re: [PATCH] ngx_http_parse_chunked might request wrong number of bytes

Maxim Dounin 533 June 28, 2013 06:26AM



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

Online Users

Guests: 310
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