]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hpack: validate idx > 0 in hpack_valid_idx()
authorWilly Tarreau <w@1wt.eu>
Tue, 28 Apr 2026 01:56:35 +0000 (03:56 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 07:33:31 +0000 (09:33 +0200)
HPACK indices start at 1, so idx=0 is invalid. The function only checked
the upper bound before, allowing idx=0 to pass as valid. This is harmless
as the code properly checks for existing name and values everywhere, but
then due to the call to hpack_idx_to_phdr(), index 0 will be taken for
:authority. Let's just make sure it's never zero.

This can be backported.

include/haproxy/hpack-tbl.h

index 02cf7db5432239991e23d2dfc89e526d20bd679f..becabf21b6bede7d4ef51df6f7650a7ef0ead283 100644 (file)
@@ -78,7 +78,7 @@ static inline const struct hpack_dte *hpack_get_dte(const struct hpack_dht *dht,
 /* returns non-zero if <idx> is valid for table <dht> */
 static inline int hpack_valid_idx(const struct hpack_dht *dht, uint32_t idx)
 {
-       return idx < dht->used + HPACK_SHT_SIZE;
+       return idx > 0 && idx < dht->used + HPACK_SHT_SIZE;
 }
 
 /* return a pointer to the header name for entry <dte>. */