]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ech: non destructive parsing in cli_find_ech_specific_ctx()
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 30 Oct 2025 10:54:49 +0000 (11:54 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 30 Oct 2025 10:59:39 +0000 (11:59 +0100)
 cli_find_ech_specific_ctx() parses the <frontend>/<bind_conf> and sets
 a \0 in place the '/'. But the originals tring is still used to emit
 messages in the CLI so we only output the frontend part.

 This patch do the parsing in a trash buffer instead.

src/ech.c

index 717f18ba1f715dfde7744ce13bbe17d0585dd8e3..2acd898e124470e514c3f1b8428ecc4cb1f68a03 100644 (file)
--- a/src/ech.c
+++ b/src/ech.c
@@ -84,25 +84,27 @@ end:
        return rv;
 }
 
-/*
+/* find a named SSL_CTX, returns 1 if found
+ *
  * <name> should be in the format "frontend/@<filename>:<linenum>"
  * Example:
  *   "http1/@haproxy.cfg:1234"
- *
  */
-
-/* find a named SSL_CTX, returns 1 if found */
-static int cli_find_ech_specific_ctx(char *name, SSL_CTX **sctx)
+static int cli_find_ech_specific_ctx(const char *name, SSL_CTX **sctx)
 {
        struct proxy *p;
        struct bind_conf *bind_conf;
        char *pname; /* proxy name */
        char *bname; /* bind_name */
+       struct buffer *tmp = get_trash_chunk();
 
        if (!name || !sctx)
                return 0;
 
-       for (pname = bname = name; *bname != '\0' && *bname != '/'; bname++)
+
+       b_putblk(tmp, name, strlen(name) + 1);
+
+       for (pname = bname = tmp->area; *bname != '\0' && *bname != '/'; bname++)
                ;
 
        if (*bname) {