]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl/crtlist: handle crt_path == cc->crt in crtlist_load_crt()
authorWilliam Lallemand <wlallemand@haproxy.com>
Wed, 12 Feb 2025 14:29:39 +0000 (15:29 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 17 Feb 2025 17:26:37 +0000 (18:26 +0100)
Handle the case where crt_path == cc->crt, so the pointer doesn't get
free'd before getting strdup'ed in crtlist_load_crt().

src/ssl_crtlist.c

index 0e3bbb0976b2799f42a519a2ea98a1b1a1e07462..1caaed7fdca933f29e7cdd39ac380100c4fa3a8e 100644 (file)
@@ -520,11 +520,14 @@ int crtlist_load_crt(char *crt_path, struct ckch_conf *cc, struct crtlist *newli
        if (ckchs == NULL) {
                if (stat(crt_path, &st) == 0) {
                        found++;
-                       free(cc->crt);
-                       cc->crt = strdup(crt_path);
-                       if (cc->crt == NULL) {
-                               cfgerr |= ERR_ALERT | ERR_FATAL;
-                               goto error;
+
+                       if (crt_path != cc->crt) {
+                               free(cc->crt);
+                               cc->crt = strdup(crt_path);
+                               if (cc->crt == NULL) {
+                                       cfgerr |= ERR_ALERT | ERR_FATAL;
+                                       goto error;
+                               }
                        }
 
                        ckchs = ckch_store_new_load_files_conf(crt_path, cc, err);