]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl/ckch: warn when the same keyword was used twice
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 9 May 2025 17:18:38 +0000 (19:18 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 9 May 2025 17:18:38 +0000 (19:18 +0200)
When using a crt-list or a crt-store, keywords mentionned twice on the
same line overwritte the previous value.

This patch emits a warning when the same keyword is found another time
on the same line.

src/ssl_ckch.c

index a2e96dd36dd63dcd45196583fe1c61b5952dbb27..57f1c3e91eea2d3ad91eed01fed2f252a077bb3f 100644 (file)
@@ -4870,7 +4870,12 @@ int ckch_conf_parse(char **args, int cur_arg, struct ckch_conf *f, int *found, c
                        if (ckch_conf_kws[i].type == PARSE_TYPE_STR) {
                                char **t = target;
 
-                               ha_free(t);
+                               if (*t) {
+                                       ha_free(t);
+                                       memprintf(err, "'%s' already specified, overwriting.", ckch_conf_kws[i].name);
+                                       err_code |= ERR_WARN;
+                               }
+
                                *t = strdup(args[cur_arg + 1]);
                                if (!*t) {
                                        ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
@@ -4884,7 +4889,11 @@ int ckch_conf_parse(char **args, int cur_arg, struct ckch_conf *f, int *found, c
                                char *b, *e;
 
                                /* split a string into substring split by colons */
-                               ha_freearray(t);
+                               if (*t) {
+                                       ha_freearray(t);
+                                       memprintf(err, "'%s' already specified, overwriting.", ckch_conf_kws[i].name);
+                                       err_code |= ERR_WARN;
+                               }
                                e = b = args[cur_arg + 1];
                                do {
                                        while (*e != ',' && *e != '\0')