From b6149e203f919c899fefc702a17fbb78bdec3700 Mon Sep 17 00:00:00 2001
From: Le Van Khanh <Khanh.LeVan@vn.bosch.com>
Date: Thu, 9 Feb 2023 03:17:13 -0500
Subject: [PATCH] Fix memory leak

Free the ecuid_conf in case of memory alllocated

CVE: CVE-2023-26257

Upstream-Status: Backport
[https://github.com/COVESA/dlt-daemon/pull/441/commits/b6149e203f919c899fefc702a17fbb78bdec3700]

Signed-off-by: Le Van Khanh <Khanh.LeVan@vn.bosch.com>

Signed-off-by: Yogita Urade <yogita.urade@windriver.com>
---
 src/console/dlt-control-common.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/console/dlt-control-common.c b/src/console/dlt-control-common.c
index abcaf92..64951c1 100644
--- a/src/console/dlt-control-common.c
+++ b/src/console/dlt-control-common.c
@@ -124,6 +124,8 @@ void set_ecuid(char *ecuid)
             if (dlt_parse_config_param("ECUId", &ecuid_conf) == 0) {
                 memset(local_ecuid, 0, DLT_CTRL_ECUID_LEN);
                 strncpy(local_ecuid, ecuid_conf, DLT_CTRL_ECUID_LEN);
+                if (ecuid_conf !=NULL)
+                    free(ecuid_conf);
                 local_ecuid[DLT_CTRL_ECUID_LEN - 1] = '\0';
             }
             else {
--
2.34.1
