BUG/MAJOR: hpack: fix length check for short names encoding
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.
diff --git a/src/hpack-enc.c b/src/hpack-enc.c
index 818a0ab..1e57153 100644
--- a/src/hpack-enc.c
+++ b/src/hpack-enc.c
@@ -177,7 +177,7 @@
}
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);