]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: qpack: Fix index calculation in debug functions
authorFrederic Lecaille <flecaille@haproxy.com>
Tue, 26 May 2026 09:26:23 +0000 (11:26 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Wed, 27 May 2026 16:40:53 +0000 (18:40 +0200)
Although qpack_idx_to_name and qpack_idx_to_value are currently only
called within uncompiled debug code, they contained an index bug. They
passed absolute indexes directly to qpack_get_dte instead of relative
dynamic table indexes.

This patch fixes the logic by subtracting QPACK_SHT_SIZE and guarding
against static table index lookups.

Should be easily backported to all versions.

include/haproxy/qpack-tbl.h

index 05f3ab4c69933b9bcae3d54d8babed6bf043648e..ef934f86bba502efa78ac4caa9f09e6b39b56e5d 100644 (file)
@@ -93,24 +93,30 @@ static inline struct ist qpack_get_value(const struct qpack_dht *dht, const stru
        return ret;
 }
 
-/* takes an idx, returns the associated name */
+/* takes an absolute idx (including static table offset), returns the associated name */
 static inline struct ist qpack_idx_to_name(const struct qpack_dht *dht, uint32_t idx)
 {
        const struct qpack_dte *dte;
 
-       dte = qpack_get_dte(dht, idx);
+       if (idx < QPACK_SHT_SIZE)
+               return ist("### ERR ###"); /* static table entries not accessible via dht */
+
+       dte = qpack_get_dte(dht, idx - QPACK_SHT_SIZE);
        if (!dte)
                return ist("### ERR ###"); // error
 
        return qpack_get_name(dht, dte);
 }
 
-/* takes an idx, returns the associated value */
+/* takes an absolute idx (including static table offset), returns the associated value */
 static inline struct ist qpack_idx_to_value(const struct qpack_dht *dht, uint32_t idx)
 {
        const struct qpack_dte *dte;
 
-       dte = qpack_get_dte(dht, idx);
+       if (idx < QPACK_SHT_SIZE)
+               return ist("### ERR ###"); /* static table entries not accessible via dht */
+
+       dte = qpack_get_dte(dht, idx - QPACK_SHT_SIZE);
        if (!dte)
                return ist("### ERR ###"); // error