From 3a9e5d1671c6096fed41d7f6dc50cc28479ee55c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 21 Apr 2021 14:30:02 -0400 Subject: [PATCH] Fix: relayd: leak of config_path on duplicate --config option MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 1452207 Resource leak The system resource will not be reclaimed and reused, reducing the future availability of the resource. In lttng_notification_create_from_payload: Leak of memory or pointers to system resources (CWE-404) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: Ib4f6b388f4ff24eedcbff64570bd9fa10a445304 --- src/bin/lttng-relayd/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 9f094f542..bdc27475e 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -520,7 +520,7 @@ static int set_options(int argc, char **argv) int c, ret = 0, option_index = 0, retval = 0; int orig_optopt = optopt, orig_optind = optind; char *default_address, *optstring; - const char *config_path = NULL; + char *config_path = NULL; optstring = utils_generate_optstring(long_options, sizeof(long_options) / sizeof(struct option)); @@ -544,6 +544,7 @@ static int set_options(int argc, char **argv) WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.", "-f, --config"); } else { + free(config_path); config_path = utils_expand_path(optarg); if (!config_path) { ERR("Failed to resolve path: %s", optarg); @@ -656,6 +657,7 @@ static int set_options(int argc, char **argv) } exit: + free(config_path); free(optstring); return retval; } -- 2.34.1