]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: checks: handle a possible strdup() failure
authorIlia Shipitsin <chipitsine@gmail.com>
Mon, 23 Dec 2024 20:59:37 +0000 (21:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 25 Dec 2024 11:40:56 +0000 (12:40 +0100)
This defect was found by the coccinelle script "unchecked-strdup.cocci".
It can be backported to all supported branches.

src/check.c

index 29a86b7dd37cc5a37b4fbb139dce312b87cd54df..dde1e72b0902508f0dddc8a40875a76cee3995a0 100644 (file)
@@ -1667,6 +1667,10 @@ static int start_checks()
        /* 0- init the dummy frontend used to create all checks sessions */
        init_new_proxy(&checks_fe);
        checks_fe.id = strdup("CHECKS-FE");
+       if (!checks_fe.id) {
+               ha_alert("Out of memory creating the checks frontend.\n");
+               return ERR_ALERT | ERR_FATAL;
+       }
        checks_fe.cap = PR_CAP_FE | PR_CAP_BE;
         checks_fe.mode = PR_MODE_TCP;
        checks_fe.maxconn = 0;