fix bug of memory free
Signed-off-by: wujing <wujing50@huawei.com>
This commit is contained in:
parent
79ab1b2d28
commit
b4ff9620e4
98
0039-fix-bug-of-memory-free.patch
Normal file
98
0039-fix-bug-of-memory-free.patch
Normal file
@ -0,0 +1,98 @@
|
||||
From b235b7526f452dab2db7f9de71ea27b3dfacde1a Mon Sep 17 00:00:00 2001
|
||||
From: wujing <wujing50@huawei.com>
|
||||
Date: Sat, 9 Apr 2022 15:15:02 +0800
|
||||
Subject: [PATCH] fix bug of memory free
|
||||
|
||||
Signed-off-by: wujing <wujing50@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
13
lxc.spec
13
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<wujing50@huawei.com> - 4.0.3-2022040901
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: fix bug of memory free
|
||||
|
||||
* Thu Mar 17 2022 haozi007<liuhao27@huawei.com> - 4.0.3-2022031701
|
||||
- Type:improv
|
||||
- Type:improve
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: fix unnecessary print error message
|
||||
|
||||
* Mon Feb 21 2022 chegJH <hejunjie10@huawei.com> - 4.0.3-2022022101
|
||||
- Type:improv
|
||||
- Type:improve
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: fix alwasy print and len
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user