]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl/crtlist: alloc ssl_conf only when a valid keyword is found
authorWilliam Lallemand <wlallemand@haproxy.com>
Wed, 10 Apr 2024 17:05:15 +0000 (19:05 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 12 Apr 2024 13:38:54 +0000 (15:38 +0200)
crt-list will be enhanced with ckch_conf keywords, however these keywords
does not fill the 'ssl_conf' structure. So we don't need to allocate the
ssl_conf for every options between [ ] but only when we found a relevant
one.

src/ssl_crtlist.c

index ff7f279854da9ffb1b20099cc85371f5b57e7b3e..3b1f5329502cf0c824ad3c5c90a5aa86b79ae09b 100644 (file)
@@ -438,12 +438,6 @@ int crtlist_parse_line(char *line, char **crt_path, struct crtlist_entry *entry,
                        cfgerr |= ERR_WARN;
                }
 
-               ssl_conf = calloc(1, sizeof *ssl_conf);
-               if (!ssl_conf) {
-                       memprintf(err, "not enough memory!");
-                       cfgerr |= ERR_ALERT | ERR_FATAL;
-                       goto error;
-               }
        }
 
        cur_arg = ssl_b ? ssl_b : 1;
@@ -451,6 +445,14 @@ int crtlist_parse_line(char *line, char **crt_path, struct crtlist_entry *entry,
                newarg = 0;
                for (i = 0; ssl_crtlist_kws[i].kw != NULL; i++) {
                        if (strcmp(ssl_crtlist_kws[i].kw, args[cur_arg]) == 0) {
+                               if (!ssl_conf)
+                                       ssl_conf = calloc(1, sizeof *ssl_conf);
+                               if (!ssl_conf) {
+                                       memprintf(err, "not enough memory!");
+                                       cfgerr |= ERR_ALERT | ERR_FATAL;
+                                       goto error;
+                               }
+
                                newarg = 1;
                                cfgerr |= ssl_crtlist_kws[i].parse(args, cur_arg, NULL, ssl_conf, from_cli, err);
                                if (cur_arg + 1 + ssl_crtlist_kws[i].skip > ssl_e) {