From: Christopher Faulet Date: Thu, 3 Dec 2026 14:12:46 +0000 (+0100) Subject: BUG/MINOR: h1: use the right masks to test the accepted HTTP violations X-Git-Url: https://git.kaiwu.me/web/http/virtual_hosts.html?a=commitdiff_plain;h=4c4b337794a6ad0a57ab4f15d0a4ec6aae00a143;p=haproxy.git BUG/MINOR: h1: use the right masks to test the accepted HTTP violations 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. --- diff --git a/src/h1.c b/src/h1.c index db70dcb5a..563a1b773 100644 --- 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; } diff --git a/src/h1_htx.c b/src/h1_htx.c index 10838b12b..0698a95dc 100644 --- a/src/h1_htx.c +++ b/src/h1_htx.c @@ -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;