]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: hpack: fix length check for short names encoding
authorWilly Tarreau <w@1wt.eu>
Sun, 16 Dec 2018 08:38:30 +0000 (09:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 16 Dec 2018 08:38:30 +0000 (09:38 +0100)
Commit 19ed92b ("MINOR: hpack: optimize header encoding for short names")
introduced an error in the space computation for short names, as it removed
the length encoding from the count without replacing with 1 (the minimum
byte). This results in the last byte of the area being occasionally
overwritten, which is immediately detected with -DDEBUG_MEMORY_POOLS as
the canary at the end gets overwritten.

No backport is needed.

src/hpack-enc.c

index 818a0abd7b7b4cd4de85892d44f18c8637ad7458..1e57153f22b64bb4550b6f62520ab615afa848d7 100644 (file)
@@ -177,7 +177,7 @@ int hpack_encode_header(struct buffer *out, const struct ist n,
        }
 
  make_literal:
-       if (likely(n.len < 127 && len + 1 + n.len <= size)) {
+       if (likely(n.len < 127 && len + 2 + n.len <= size)) {
                out->area[len++] = 0x00;      /* literal without indexing -- new name */
                out->area[len++] = n.len;     /* single-byte length encoding */
                ist2bin(out->area + len, n);