changeset 8349:b13176e717ba quic

HTTP/3: fixed encoding variable-length integers.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 21 Apr 2020 17:11:49 +0300
parents d42b50d239f4
children 47dac6e0521a
files src/http/v3/ngx_http_v3.c
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/v3/ngx_http_v3.c
+++ b/src/http/v3/ngx_http_v3.c
@@ -34,21 +34,25 @@ ngx_http_v3_encode_varlen_int(u_char *p,
 
     if (value <= 1073741823) {
         if (p == NULL) {
-            return 3;
+            return 4;
         }
 
-        *p++ = 0x80 | (value >> 16);
+        *p++ = 0x80 | (value >> 24);
+        *p++ = (value >> 16);
         *p++ = (value >> 8);
         *p++ = value;
         return (uintptr_t) p;
-
     }
 
     if (p == NULL) {
-        return 4;
+        return 8;
     }
 
-    *p++ = 0xc0 | (value >> 24);
+    *p++ = 0xc0 | (value >> 56);
+    *p++ = (value >> 48);
+    *p++ = (value >> 40);
+    *p++ = (value >> 32);
+    *p++ = (value >> 24);
     *p++ = (value >> 16);
     *p++ = (value >> 8);
     *p++ = value;