]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl_crtlist: handle a possible strdup() failure
authorIlia Shipitsin <chipitsine@gmail.com>
Tue, 3 Dec 2024 16:13:05 +0000 (17:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 10 Dec 2024 07:05:42 +0000 (08:05 +0100)
This defect was found by the coccinelle script "unchecked-strdup.cocci".
It can be backported to all supported branches.

src/ssl_crtlist.c

index 71fa0a0b1e870ec18414153fd5b6e1f196731320..189d6e6ca147bc80cbcc299361cfb455e08b884b 100644 (file)
@@ -608,6 +608,11 @@ int crtlist_parse_file(char *file, struct bind_conf *bind_conf, struct proxy *cu
                                found++;
                                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);
                                if (ckchs == NULL) {
                                        cfgerr |= ERR_ALERT | ERR_FATAL;