iSulad/0047-handle-security-warning-for-cleanup-module.patch
zhangxiaoyu 313d1dbcd1 update from upstream
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
2022-12-06 14:34:53 +08:00

97 lines
2.9 KiB
Diff

From 9c056dc6d696d3eabd192ad6b396e27bb5846362 Mon Sep 17 00:00:00 2001
From: "Neil.wrz" <wangrunze13@huawei.com>
Date: Thu, 17 Nov 2022 19:25:26 -0800
Subject: [PATCH 47/54] handle security warning for cleanup module
Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
---
.../container/leftover_cleanup/cleanup.c | 17 +++++++++++++----
src/daemon/modules/image/image.c | 14 +++++++++++---
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/src/daemon/modules/container/leftover_cleanup/cleanup.c b/src/daemon/modules/container/leftover_cleanup/cleanup.c
index ec9517cf..9ce1dd0c 100644
--- a/src/daemon/modules/container/leftover_cleanup/cleanup.c
+++ b/src/daemon/modules/container/leftover_cleanup/cleanup.c
@@ -82,15 +82,25 @@ static int default_cleaner()
static struct cleaners *cleaner_init()
{
+ int ret = 0;
struct cleaners *clns = create_cleaners();
if (clns == NULL) {
return NULL;
}
- add_clean_node(clns, default_cleaner, "default clean");
+ ret = add_clean_node(clns, default_cleaner, "default clean");
+ if (ret != 0) {
+ ERROR("add default_cleaner error");
+ return clns;
+ }
+
#ifdef ENABLE_OCI_IMAGE
- add_clean_node(clns, oci_rootfs_cleaner, "clean rootfs");
+ ret = add_clean_node(clns, oci_rootfs_cleaner, "clean rootfs");
+ if (ret != 0) {
+ ERROR("add oci_rootfs_cleaner error");
+ return clns;
+ }
#endif
return clns;
@@ -101,11 +111,10 @@ static void do_clean(struct cleaners * clns)
struct linked_list *it = NULL;
struct linked_list *next = NULL;
struct clean_node *c_node = NULL;
- int ret = 0;
linked_list_for_each_safe(it, &(clns->cleaner_list), next) {
c_node = (struct clean_node *)it->elem;
- if ((ret = c_node->cleaner()) != 0) {
+ if (c_node->cleaner() != 0) {
ERROR("failed to clean for: %s", c_node->desc);
} else {
DEBUG("do clean success for: %s", c_node->desc);
diff --git a/src/daemon/modules/image/image.c b/src/daemon/modules/image/image.c
index ed7d968a..fb0db361 100644
--- a/src/daemon/modules/image/image.c
+++ b/src/daemon/modules/image/image.c
@@ -1775,21 +1775,29 @@ int im_container_export(const im_export_request *request)
#ifdef ENABLE_OCI_IMAGE
char *im_get_rootfs_dir(const im_get_rf_dir_request *request) {
char *dir = NULL;
+ struct bim *bim = NULL;
if (request->type == NULL) {
ERROR("Missing image type");
return NULL;
}
- struct bim *bim = NULL;
bim = bim_get(request->type, NULL, NULL, NULL);
+
+ if (bim == NULL) {
+ ERROR("Failed to init bim, image type:%s", request->type);
+ return NULL;
+ }
+
if (bim->ops->get_dir_rf == NULL) {
ERROR("Unimplemnts get rootfs dir in %s", bim->type);
- return NULL;
+ goto out;
}
+
dir = bim->ops->get_dir_rf();
- bim_put(bim);
+out:
+ bim_put(bim);
return dir;
}
#else
--
2.25.1