]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: startup: handle a possible strdup() failure
authorEgor Shestakov <egor@ved1.me>
Thu, 5 Feb 2026 08:55:58 +0000 (08:55 +0000)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 Feb 2026 09:50:31 +0000 (10:50 +0100)
Fix unhandled strdup() failure when initializing global.log_tag.

Bug was introduced with the fix UAF for global progname pointer from
351ae5dbe. So it must be backported as far as 3.1.

src/haproxy.c

index 0ae755faaaea26c3848ca0ac405cb66584421fa3..48186a66a082a2ab57b9fe00e11bf0e8a09d9cf5 100644 (file)
@@ -1441,6 +1441,10 @@ static void init_early(int argc, char **argv)
        }
 
        chunk_initlen(&global.log_tag, strdup(progname), len, len);
+       if (b_orig(&global.log_tag) == NULL) {
+               ha_alert("Cannot allocate memory for log_tag.\n");
+               exit(EXIT_FAILURE);
+       }
 }
 
 /* handles program arguments. Very minimal parsing is performed, variables are