!267 do not free the pointer returned by dirname

From: @wangfengtu 
Reviewed-by: @jingwoo 
Signed-off-by: @jingwoo
This commit is contained in:
openeuler-ci-bot 2022-04-21 08:45:22 +00:00 committed by Gitee
commit 4360c7302a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,38 @@
From 11621ec06e911395c9bb3b5ae5d8f47cfc02ce3e Mon Sep 17 00:00:00 2001
From: WangFengTu <wangfengtu@huawei.com>
Date: Thu, 21 Apr 2022 15:59:11 +0800
Subject: [PATCH] do not free the pointer returned by dirname
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
---
src/lxc/conf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 7c2619c..cd9e818 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -4258,6 +4258,7 @@ static int setup_populate_devs(const struct lxc_rootfs *rootfs, struct lxc_list
INFO("Populating devices into container");
cur_mask = umask(0000);
lxc_list_for_each(it, devs) {
+ __do_free char *tmp_path = NULL;
ret = 0;
dev_elem = it->elem;
@@ -4268,10 +4269,9 @@ static int setup_populate_devs(const struct lxc_rootfs *rootfs, struct lxc_list
}
/* create any missing directories */
- pathdirname = safe_strdup(path);
- pathdirname = dirname(pathdirname);
+ tmp_path = safe_strdup(path);
+ pathdirname = dirname(tmp_path);
ret = mkdir_p(pathdirname, 0755);
- free(pathdirname);
if (ret < 0) {
WARN("Failed to create target directory");
ret = -1;
--
2.25.1

View File

@ -48,6 +48,7 @@ Patch0037: 0037-fix-always-print-and-temp-len.patch
Patch0038: 0038-just-print-error-when-new-lock-failed.patch Patch0038: 0038-just-print-error-when-new-lock-failed.patch
Patch0039: 0039-fix-bug-of-memory-free.patch Patch0039: 0039-fix-bug-of-memory-free.patch
Patch0040: 0040-refactor-the-way-to-convert-selinux-label-to-shared.path Patch0040: 0040-refactor-the-way-to-convert-selinux-label-to-shared.path
Patch0041: 0041-do-not-free-the-pointer-returned-by-dirname.patch
BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath
BuildRequires: pkgconfig(libseccomp) BuildRequires: pkgconfig(libseccomp)

View File

@ -38,3 +38,4 @@
0038-just-print-error-when-new-lock-failed.patch 0038-just-print-error-when-new-lock-failed.patch
0039-fix-bug-of-memory-free.patch 0039-fix-bug-of-memory-free.patch
0040-refactor-the-way-to-convert-selinux-label-to-shared.path 0040-refactor-the-way-to-convert-selinux-label-to-shared.path
0041-do-not-free-the-pointer-returned-by-dirname.patch