From: Roman Arutyunyan Date: Wed, 16 Sep 2020 19:21:03 +0000 (+0100) Subject: HTTP/3: rearranged length check when parsing header. X-Git-Tag: release-1.25.0~4^2~557 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=be719bbec8a9130223e25c4c22b52a73c44eb1ec;p=nginx.git HTTP/3: rearranged length check when parsing header. The new code looks simpler and is similar to other checks. --- diff --git a/src/http/v3/ngx_http_v3_parse.c b/src/http/v3/ngx_http_v3_parse.c index 96f87b0b6..6ce5f10a7 100644 --- a/src/http/v3/ngx_http_v3_parse.c +++ b/src/http/v3/ngx_http_v3_parse.c @@ -212,6 +212,10 @@ ngx_http_v3_parse_headers(ngx_connection_t *c, ngx_http_v3_parse_headers_t *st, break; } + if (st->length == 0) { + return NGX_HTTP_V3_ERR_FRAME_ERROR; + } + st->state = sw_prefix; break; @@ -225,7 +229,7 @@ ngx_http_v3_parse_headers(ngx_connection_t *c, ngx_http_v3_parse_headers_t *st, case sw_prefix: - if (st->length-- == 0) { + if (--st->length == 0) { return NGX_HTTP_V3_ERR_FRAME_ERROR; } @@ -234,10 +238,6 @@ ngx_http_v3_parse_headers(ngx_connection_t *c, ngx_http_v3_parse_headers_t *st, return rc; } - if (st->length == 0) { - return NGX_HTTP_V3_ERR_FRAME_ERROR; - } - st->state = sw_verify; break;