]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: qpack: properly handle invalid dynamic table references
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 30 Jun 2022 07:30:23 +0000 (09:30 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 30 Jun 2022 09:51:06 +0000 (11:51 +0200)
Return QPACK_DECOMPRESSION_FAILED error code when dealing with dynamic
table references. This is justified as for now haproxy does not
implement dynamic table support and advertizes a zero-sized table.

The H3 calling function will thus reuse this code in a CONNECTION_CLOSE
frame, in conformance with the QPACK RFC.

This proper error management allows to remove obsolete ABORT_NOW guards.

src/qpack-dec.c

index 8fa19b1724f58a596753419c1c84ca9a6d96fcb4..aa30121e47b3b81de0cfaf2eaaf14aa7531599b2 100644 (file)
@@ -220,12 +220,7 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
 
                if (efl_type == QPACK_LFL_WPBNM) {
                        /* Literal field line with post-base name reference
-                        *
-                        * TODO not implemented
-                        *
-                        * For the moment, this should never happen as
-                        * currently we do not support dynamic table insertion
-                        * and specify an empty table size.
+                        * TODO adjust this when dynamic table support is implemented.
                         */
 #if 0
                        uint64_t index __maybe_unused, length;
@@ -260,16 +255,20 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
                        raw += length;
                        len -= length;
 #endif
-                       ABORT_NOW(); /* dynamic table not supported */
+
+                       /* RFC9204 2.2.3 Invalid References
+                        *
+                        * If the decoder encounters a reference in a field line representation
+                        * to a dynamic table entry that has already been evicted or that has an
+                        * absolute index greater than or equal to the declared Required Insert
+                        * Count (Section 4.5.1), it MUST treat this as a connection error of
+                        * type QPACK_DECOMPRESSION_FAILED.
+                        */
+                       return -QPACK_DECOMPRESSION_FAILED;
                }
                else if (efl_type == QPACK_IFL_WPBI) {
                        /* Indexed field line with post-base index
-                        *
-                        * TODO not implemented
-                        *
-                        * For the moment, this should never happen as
-                        * currently we do not support dynamic table insertion
-                        * and specify an empty table size.
+                        * TODO adjust this when dynamic table support is implemented.
                         */
 #if 0
                        uint64_t index __maybe_unused;
@@ -284,7 +283,16 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
 
                        qpack_debug_printf(stderr, " index=%llu", (unsigned long long)index);
 #endif
-                       ABORT_NOW(); /* dynamic table not supported */
+
+                       /* RFC9204 2.2.3 Invalid References
+                        *
+                        * If the decoder encounters a reference in a field line representation
+                        * to a dynamic table entry that has already been evicted or that has an
+                        * absolute index greater than or equal to the declared Required Insert
+                        * Count (Section 4.5.1), it MUST treat this as a connection error of
+                        * type QPACK_DECOMPRESSION_FAILED.
+                        */
+                       return -QPACK_DECOMPRESSION_FAILED;
                }
                else if (efl_type & QPACK_IFL_BIT) {
                        /* Indexed field line */
@@ -305,13 +313,17 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
                                value = qpack_sht[index].v;
                        }
                        else {
-                               /* TODO not implemented
+                               /* RFC9204 2.2.3 Invalid References
+                                *
+                                * If the decoder encounters a reference in a field line representation
+                                * to a dynamic table entry that has already been evicted or that has an
+                                * absolute index greater than or equal to the declared Required Insert
+                                * Count (Section 4.5.1), it MUST treat this as a connection error of
+                                * type QPACK_DECOMPRESSION_FAILED.
                                 *
-                                * For the moment, this should never happen as
-                                * currently we do not support dynamic table insertion
-                                * and specify an empty table size.
+                                * TODO adjust this when dynamic table support is implemented.
                                 */
-                               ABORT_NOW();
+                               return -QPACK_DECOMPRESSION_FAILED;
                        }
 
                        qpack_debug_printf(stderr,  " t=%d index=%llu", !!static_tbl, (unsigned long long)index);
@@ -335,13 +347,17 @@ int qpack_decode_fs(const unsigned char *raw, uint64_t len, struct buffer *tmp,
                                name = qpack_sht[index].n;
                        }
                        else {
-                               /* TODO not implemented
+                               /* RFC9204 2.2.3 Invalid References
+                                *
+                                * If the decoder encounters a reference in a field line representation
+                                * to a dynamic table entry that has already been evicted or that has an
+                                * absolute index greater than or equal to the declared Required Insert
+                                * Count (Section 4.5.1), it MUST treat this as a connection error of
+                                * type QPACK_DECOMPRESSION_FAILED.
                                 *
-                                * For the moment, this should never happen as
-                                * currently we do not support dynamic table insertion
-                                * and specify an empty table size.
+                                * TODO adjust this when dynamic table support is implemented.
                                 */
-                               ABORT_NOW();
+                               return -QPACK_DECOMPRESSION_FAILED;
                        }
 
                        qpack_debug_printf(stderr, " n=%d t=%d index=%llu", !!n, !!static_tbl, (unsigned long long)index);