From d8ee6459cc2ced2dd8c5f78123548b223c9551f7 Mon Sep 17 00:00:00 2001 From: WangFengTu Date: Thu, 21 Apr 2022 16:05:35 +0800 Subject: [PATCH] do not free the pointer returned by dirname Signed-off-by: WangFengTu --- ...free-the-pointer-returned-by-dirname.patch | 38 +++++++++++++++++++ lxc.spec | 1 + series.conf | 1 + 3 files changed, 40 insertions(+) create mode 100644 0041-do-not-free-the-pointer-returned-by-dirname.patch diff --git a/0041-do-not-free-the-pointer-returned-by-dirname.patch b/0041-do-not-free-the-pointer-returned-by-dirname.patch new file mode 100644 index 0000000..28e1da5 --- /dev/null +++ b/0041-do-not-free-the-pointer-returned-by-dirname.patch @@ -0,0 +1,38 @@ +From 11621ec06e911395c9bb3b5ae5d8f47cfc02ce3e Mon Sep 17 00:00:00 2001 +From: WangFengTu +Date: Thu, 21 Apr 2022 15:59:11 +0800 +Subject: [PATCH] do not free the pointer returned by dirname + +Signed-off-by: WangFengTu +--- + 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 + diff --git a/lxc.spec b/lxc.spec index 1adf41a..d8504d6 100644 --- a/lxc.spec +++ b/lxc.spec @@ -48,6 +48,7 @@ Patch0037: 0037-fix-always-print-and-temp-len.patch Patch0038: 0038-just-print-error-when-new-lock-failed.patch Patch0039: 0039-fix-bug-of-memory-free.patch 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: pkgconfig(libseccomp) diff --git a/series.conf b/series.conf index 3e14cf0..7c6011f 100644 --- a/series.conf +++ b/series.conf @@ -38,3 +38,4 @@ 0038-just-print-error-when-new-lock-failed.patch 0039-fix-bug-of-memory-free.patch 0040-refactor-the-way-to-convert-selinux-label-to-shared.path +0041-do-not-free-the-pointer-returned-by-dirname.patch -- Gitee