here we go. v2 ср, 11 дек. 2024 г. в 07:26, Willy Tarreau <w...@1wt.eu>:
> On Wed, Dec 11, 2024 at 05:38:21AM +0100, ???? ??????? wrote: > > I'm not sure "memprintf" will succeed in case of OOM. I'll check > > No, it may also fail but anyway callers are prepared to this, and that's > the way it's handled at other places. > > Willy >
From 991078a6b8542ef33c9c255adfa39110df59f18e Mon Sep 17 00:00:00 2001 From: Ilia Shipitsin <chipits...@gmail.com> Date: Mon, 23 Dec 2024 21:59:37 +0100 Subject: [PATCH 1/4] BUG/MINOR: checks: handle a possible strdup() failure This defect was found by the coccinelle script "unchecked-strdup.cocci". It can be backported to all supported branches. --- src/check.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/check.c b/src/check.c index 29a86b7dd..dde1e72b0 100644 --- a/src/check.c +++ b/src/check.c @@ -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; -- 2.46.0.windows.1
From f101f5b1fa6e54428743bbf5f27f3abc481f4da0 Mon Sep 17 00:00:00 2001 From: Ilia Shipitsin <chipits...@gmail.com> Date: Mon, 23 Dec 2024 22:00:10 +0100 Subject: [PATCH 2/4] BUG/MINOR: listener: handle a possible strdup() failure This defect was found by the coccinelle script "unchecked-strdup.cocci". It can be backported to all supported branches. --- src/listener.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/listener.c b/src/listener.c index 5f3a98b4a..5e423eb57 100644 --- a/src/listener.c +++ b/src/listener.c @@ -2369,8 +2369,13 @@ static int bind_parse_name(char **args, int cur_arg, struct proxy *px, struct bi return ERR_ALERT | ERR_FATAL; } - list_for_each_entry(l, &conf->listeners, by_bind) + list_for_each_entry(l, &conf->listeners, by_bind) { l->name = strdup(args[cur_arg + 1]); + if (!l->name) { + memprintf(err, "'%s %s' : out of memory", args[cur_arg], args[cur_arg + 1]); + return ERR_ALERT | ERR_FATAL; + } + } return 0; } -- 2.46.0.windows.1
From 4ce470fd1e3bc499f98a81417e7ca08dd23da1a1 Mon Sep 17 00:00:00 2001 From: Ilia Shipitsin <chipits...@gmail.com> Date: Mon, 23 Dec 2024 22:01:22 +0100 Subject: [PATCH 4/4] BUG/MINOR: debug: handle a possible strdup() failure This defect was found by the coccinelle script "unchecked-strdup.cocci". It can be backported to all supported branches. --- src/debug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/debug.c b/src/debug.c index cb33cf0b2..089a6ba65 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2048,6 +2048,8 @@ static int debug_parse_cli_memstats(char **args, char *payload, struct appctx *a else if (strcmp(args[arg], "match") == 0 && *args[arg + 1]) { ha_free(&ctx->match); ctx->match = strdup(args[arg + 1]); + if (!ctx->match) + return cli_err(appctx, "Out of memory.\n"); arg++; continue; } -- 2.46.0.windows.1
From dc13fcfc8bafca457694aeca59541adce8d80f45 Mon Sep 17 00:00:00 2001 From: Ilia Shipitsin <chipits...@gmail.com> Date: Mon, 23 Dec 2024 22:00:48 +0100 Subject: [PATCH 3/4] BUG/MINOR: mux_h1: handle a possible strdup() failure This defect was found by the coccinelle script "unchecked-strdup.cocci". It can be backported to all supported branches. --- src/mux_h1.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index 7eb18133d..fb78e03d5 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -5663,7 +5663,12 @@ static int cfg_parse_h1_headers_case_adjust_file(char **args, int section_type, } free(hdrs_map.name); hdrs_map.name = strdup(args[1]); - return 0; + if (!hdrs_map.name) { + memprintf(err, "'%s %s' : out of memory", args[0], args[1]); + return -1; + } + + return 0; } /* config parser for global "tune.h1.zero-copy-fwd-recv" */ -- 2.46.0.windows.1