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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/haproxy.c b/src/haproxy.c
index 87c923714..5a07ef94d 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1440,6 +1440,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
-- 
Egor Shestakov
egor ascii(0x40) ved1 ascii(0x2E) me



Reply via email to