]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: http: use ist_find_http_ctl() instead of ist_find_ctl()
authorWilly Tarreau <w@1wt.eu>
Wed, 4 Nov 2026 16:37:11 +0000 (17:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Nov 2026 21:45:32 +0000 (22:45 +0100)
At a few places we were using ist_find_ctl() as an accelerator to locate
possibly forbidden CTL chars, but that one doesn't detect the DEL char,
so now that we have the new ist_find_http_ctl(), let's use it instead.
This is not tagged as a bug because nothing at this point is made with
this char so this doesn't make a difference at this point.

include/haproxy/http.h
src/h2.c
src/h3.c
src/http_htx.c

index aebc524eab23730b7aa74770ecea28add82975dd..5bb15a78769fa36493fc16923d2656356fc51395 100644 (file)
@@ -186,7 +186,7 @@ static inline struct http_uri_parser http_uri_parser_init(const struct ist uri)
  * 0x0D), starting at pointer <start> which must be within <ist>. Returns
  * non-zero if such a character is found, 0 otherwise. When run on unlikely
  * header match, it's recommended to first check for the presence of control
- * chars using ist_find_ctl().
+ * chars using ist_find_http_ctl().
  */
 static inline int http_header_has_forbidden_char(const struct ist ist, const char *start)
 {
@@ -218,7 +218,7 @@ static inline int http_method_has_forbidden_char(const struct ist ist)
  * 0x20, 0x23), starting at pointer <start> which must be within <ist>.
  * Returns non-zero if such a character is found, 0 otherwise. When run on
  * unlikely header match, it's recommended to first check for the presence
- * of control chars using ist_find_ctl().
+ * of control chars using ist_find_http_ctl().
  */
 static inline int http_path_has_forbidden_char(const struct ist ist, const char *start)
 {
index 2456998e800e54b5b073e8482a4b524318a68e48..bad6f57e931aca130b4ee2cc195b2dbdc26873ee 100644 (file)
--- a/src/h2.c
+++ b/src/h2.c
@@ -367,7 +367,7 @@ int h2_make_htx_request(struct http_hdr *list, struct htx *htx, unsigned int *ms
                        if (unlikely(ctl) && http_path_has_forbidden_char(list[idx].v, ctl))
                                goto fail;
                } else {
-                       ctl = ist_find_ctl(list[idx].v);
+                       ctl = ist_find_http_ctl(list[idx].v);
                        if (unlikely(ctl) && http_header_has_forbidden_char(list[idx].v, ctl))
                                goto fail;
                }
@@ -685,7 +685,7 @@ int h2_make_htx_response(struct http_hdr *list, struct htx *htx, unsigned int *m
                /* RFC7540#10.3: intermediaries forwarding to HTTP/1 must take care of
                 * rejecting NUL, CR and LF characters.
                 */
-               ctl = ist_find_ctl(list[idx].v);
+               ctl = ist_find_http_ctl(list[idx].v);
                if (unlikely(ctl) && http_header_has_forbidden_char(list[idx].v, ctl))
                        goto fail;
 
index d8cf0c28190d384e2ba2ce07d947ef319a9f2151..aad29a72cefa49a140851cce4a0cd0f00b54a983 100644 (file)
--- a/src/h3.c
+++ b/src/h3.c
@@ -563,7 +563,7 @@ static int h3_set_authority(struct qcs *qcs, struct ist *auth, const struct ist
 static int _h3_handle_phdr(struct qcs *qcs, const struct http_hdr *h)
 {
        /* look for forbidden control characters in the pseudo-header value */
-       const char *ctl = ist_find_ctl(h->v);
+       const char *ctl = ist_find_http_ctl(h->v);
        if (unlikely(ctl) && http_header_has_forbidden_char(h->v, ctl)) {
                TRACE_ERROR("control character present in pseudo-header value", H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);
                goto err;
@@ -610,7 +610,7 @@ static int _h3_handle_hdr(struct qcs *qcs, const struct http_hdr *hdr)
         */
 
        /* look for forbidden control characters in the header value */
-       ctl = ist_find_ctl(value);
+       ctl = ist_find_http_ctl(value);
        if (unlikely(ctl) && http_header_has_forbidden_char(value, ctl)) {
                TRACE_ERROR("control character present in header value", H3_EV_RX_FRAME|H3_EV_RX_HDR, qcs->qcc->conn, qcs);
                goto err;
index 8dbe1bd63135627bab916623de4b0c672365f85d..2c1e5cd6f80456af6573aca36a2681202d354c92 100644 (file)
@@ -2062,7 +2062,7 @@ enum http_parser_status http_trailers_to_htx(struct http_hdr *list, struct htx *
                 *   response that contains a character not permitted in a field
                 *   value MUST be treated as malformed
                 */
-               ctl = ist_find_ctl(list[idx].v);
+               ctl = ist_find_http_ctl(list[idx].v);
                if (unlikely(ctl) && http_header_has_forbidden_char(list[idx].v, ctl)) {
                        ret = HTTP_PRS_INV_HVAL;
                        goto fail;