# HG changeset patch # User Roman Arutyunyan # Date 1600284063 -3600 # Node ID 351d62300832fcadebbf7d6463f1631590bf0a29 # Parent 5a794d2452efd929ca6812c922746c976e7b21d6 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 --- 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 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 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 return rc; } - if (st->length == 0) { - return NGX_HTTP_V3_ERR_FRAME_ERROR; - } - st->state = sw_verify; break;