diff --git a/0039-fix-bug-of-memory-free.patch b/0039-fix-bug-of-memory-free.patch new file mode 100644 index 0000000000000000000000000000000000000000..c38bbfb7551749d13db955a32635be7709271385 --- /dev/null +++ b/0039-fix-bug-of-memory-free.patch @@ -0,0 +1,98 @@ +From b235b7526f452dab2db7f9de71ea27b3dfacde1a Mon Sep 17 00:00:00 2001 +From: wujing +Date: Sat, 9 Apr 2022 15:15:02 +0800 +Subject: [PATCH] fix bug of memory free + +Signed-off-by: wujing +--- + src/lxc/conf.c | 27 ++++++++++----------------- + 1 file changed, 10 insertions(+), 17 deletions(-) + +diff --git a/src/lxc/conf.c b/src/lxc/conf.c +index 19e193dd..4ef154e6 100644 +--- a/src/lxc/conf.c ++++ b/src/lxc/conf.c +@@ -2604,70 +2604,63 @@ static int check_mount_destination(const char *rootfs, const char *dest, const c + const char **invalid = NULL; + + for(valid = valid_destinations; *valid != NULL; valid++) { +- char *fullpath = NULL; +- char *relpath = NULL; ++ __do_free char *fullpath = NULL; ++ __do_free char *relpath = NULL; + const char *parts[3] = { + rootfs, + *valid, + NULL + }; + fullpath = lxc_string_join("/", parts, false); +- if (!fullpath) { ++ if (fullpath == NULL) { + ERROR("Out of memory"); + return -1; + } + relpath = path_relative(fullpath, dest); +- free(fullpath); +- if (!relpath) ++ if (relpath == NULL) { ++ ERROR("Failed to get relpath for %s related to %s", dest, fullpath); + return -1; ++ } + if (!strcmp(relpath, ".")) { +- free(relpath); + return 0; + } +- free(relpath); + } + + for(invalid = invalid_destinations; *invalid != NULL; invalid++) { +- char *fullpath = NULL; +- char *relpath = NULL; ++ __do_free char *fullpath = NULL; ++ __do_free char *relpath = NULL; + const char *parts[3] = { + rootfs, + *invalid, + NULL + }; + fullpath = lxc_string_join("/", parts, false); +- if (!fullpath) { ++ if (fullpath == NULL) { + ERROR("Out of memory"); + return -1; + } + relpath = path_relative(fullpath, dest); + DEBUG("dst path %s get relative path %s with full path %s,src:%s", dest, relpath, fullpath, src); +- free(fullpath); +- if (!relpath) { ++ if (relpath == NULL) { + ERROR("Failed to get relpath for %s related to %s", dest, fullpath); + return -1; + } + // pass if the mount path is outside of invalid proc + if (strncmp(relpath, "..", 2) == 0) { +- free(relpath); + continue; + } + if (strcmp(relpath, ".") == 0) { + if (src == NULL) { +- free(relpath); + continue; + } + // pass if the mount on top of /proc and the source of the mount is a proc filesystem + if (has_fs_type(src, PROC_SUPER_MAGIC)) { + WARN("src %s is proc allow mount on-top of %s", src, *invalid); +- free(relpath); + continue; + } + ERROR("%s cannot be mounted because it is located inside %s", dest, *invalid); +- free(relpath); + return -1; + } +- free(relpath); + } + + return 0; +-- +2.35.1 + diff --git a/lxc.spec b/lxc.spec index 5a5c9c739d3d4f5e8de2a398c66846a125ec3ad7..c7de1c8ce878ac6f4d628b58f790874f2b673727 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 2022031701 +%global _release 2022040901 Name: lxc Version: 4.0.3 @@ -46,6 +46,7 @@ Patch0035: 0035-adapt-upstream-compiler-settings.patch Patch0036: 0036-compile-in-android-env.patch 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 BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: pkgconfig(libseccomp) @@ -217,14 +218,20 @@ make check %{_mandir}/*/man7/%{name}* %changelog +* Sat Apr 09 2022 wujing - 4.0.3-2022040901 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: fix bug of memory free + * Thu Mar 17 2022 haozi007 - 4.0.3-2022031701 -- Type:improv +- Type:improve - ID:NA - SUG:NA - DESC: fix unnecessary print error message * Mon Feb 21 2022 chegJH - 4.0.3-2022022101 -- Type:improv +- Type:improve - ID:NA - SUG:NA - DESC: fix alwasy print and len diff --git a/series.conf b/series.conf index eb4eb1507830fd9aec44760d4ea45e211e9697e7..9e9f9c2504a3a59e1e2ca5c708613ee6179cce6f 100644 --- a/series.conf +++ b/series.conf @@ -36,3 +36,4 @@ 0036-compile-in-android-env.patch 0037-fix-always-print-and-temp-len.patch 0038-just-print-error-when-new-lock-failed.patch +0039-fix-bug-of-memory-free.patch