diff options
author | Roman Arutyunyan <arut@nginx.com> | 2020-07-02 15:15:55 +0300 |
---|---|---|
committer | Roman Arutyunyan <arut@nginx.com> | 2020-07-02 15:15:55 +0300 |
commit | a7ef0da3c8b64f2b5f4d8a7e73e724a74611284c (patch) | |
tree | 8e759b348f31e10b8254c2f37c17d9efe581d087 /src/http/v3/ngx_http_v3_parse.c | |
parent | 8d41d17a12509d6f80f51a27046b7a10882892ef (diff) | |
download | nginx-a7ef0da3c8b64f2b5f4d8a7e73e724a74611284c.tar.gz nginx-a7ef0da3c8b64f2b5f4d8a7e73e724a74611284c.zip |
HTTP/3: fixed prefixed integer encoding and decoding.
Previously bytes were ordered from MSB to LSB, but the right order is the
reverse.
Diffstat (limited to 'src/http/v3/ngx_http_v3_parse.c')
-rw-r--r-- | src/http/v3/ngx_http_v3_parse.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/http/v3/ngx_http_v3_parse.c b/src/http/v3/ngx_http_v3_parse.c index 71a643d70..85491082e 100644 --- a/src/http/v3/ngx_http_v3_parse.c +++ b/src/http/v3/ngx_http_v3_parse.c @@ -91,6 +91,7 @@ ngx_int_t ngx_http_v3_parse_prefix_int(ngx_connection_t *c, ngx_http_v3_parse_prefix_int_t *st, ngx_uint_t prefix, u_char ch) { + ngx_uint_t mask; enum { sw_start = 0, sw_value @@ -100,25 +101,25 @@ ngx_http_v3_parse_prefix_int(ngx_connection_t *c, case sw_start: - st->mask = (1 << prefix) - 1; - st->value = (ch & st->mask); + mask = (1 << prefix) - 1; + st->value = ch & mask; - if (st->value != st->mask) { + if (st->value != mask) { goto done; } - st->value = 0; + st->shift = 0; st->state = sw_value; break; case sw_value: - st->value = (st->value << 7) + (ch & 0x7f); + st->value += (ch & 0x7f) << st->shift; if (ch & 0x80) { + st->shift += 7; break; } - st->value += st->mask; goto done; } |