]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: h1: use the right masks to test the accepted HTTP violations
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 14:12:46 +0000 (15:12 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 4 Dec 2026 13:53:05 +0000 (14:53 +0100)
Two tests of the accepted HTTP violations were wrong. In
h1_headers_to_hdr_list(), HTTP_VIO_HDR_VALUE_NUL was used as a mask
instead of a bit position. So the NUL character in a header value was
accepted or rejected depending on the "fragment-in-url" and the
"status-code-long" violations. And in h1_process_res_vsn(), the
response version string was checked against the acceptable request
violations instead of the response ones.

This patch must be backported to 3.5.

src/h1.c
src/h1_htx.c

index db70dcb5a8b5b42d1b663b3853d3b0ecb9136faa..563a1b77307ca9254b4eef20a952fd4aab433df0 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -974,8 +974,8 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
                                 * (like CR and LF).
                                 */
                                if (h1m->err_pos < -1 || /* PR_O2_R*BUG_OK not set */
-                                   (!(h1m->flags & H1_MF_RESP) && !(global.acc_hreq_vio & HTTP_VIO_HDR_VALUE_NUL)) ||
-                                   ((h1m->flags & H1_MF_RESP) && !(global.acc_hres_vio & HTTP_VIO_HDR_VALUE_NUL))) {
+                                   (!(h1m->flags & H1_MF_RESP) && !(global.acc_hreq_vio & (1U << HTTP_VIO_HDR_VALUE_NUL))) ||
+                                   ((h1m->flags & H1_MF_RESP) && !(global.acc_hres_vio & (1U << HTTP_VIO_HDR_VALUE_NUL)))) {
                                        state = H1_MSG_HDR_VAL;
                                        goto http_msg_invalid;
                                }
index 10838b12be6ef3ae85f4ea0c1dd6b500c9d94211..0698a95dcf7ca28a7e1d6b72288df94c74047e14 100644 (file)
@@ -106,7 +106,7 @@ static int h1_process_res_vsn(struct h1m *h1m, union h1_sl *sl)
         * exactly one digit "." one digit. This check may be disabled using
         * option accept-unsafe-violations-in-http-response.
         */
-       if (h1m->err_pos < -1 || !(global.acc_hreq_vio & (1U << HTTP_VIO_VERSION_STRING))) { /* PR_O2_RSPBUG_OK not set */
+       if (h1m->err_pos < -1 || !(global.acc_hres_vio & (1U << HTTP_VIO_VERSION_STRING))) { /* PR_O2_RSPBUG_OK not set */
                if (sl->st.v.len != 8)
                        return 0;