]> git.kaiwu.me - nginx.git/commitdiff
HTTP/3: rearranged length check when parsing header.
authorRoman Arutyunyan <arut@nginx.com>
Wed, 16 Sep 2020 19:21:03 +0000 (20:21 +0100)
committerRoman Arutyunyan <arut@nginx.com>
Wed, 16 Sep 2020 19:21:03 +0000 (20:21 +0100)
The new code looks simpler and is similar to other checks.

src/http/v3/ngx_http_v3_parse.c

index 96f87b0b6b41cb8f085527ff645a8a712563b611..6ce5f10a71e6b28569ae1f20e016366930153963 100644 (file)
@@ -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;