From 8b36d5679c8c2d783a7933dc670681dd3a8dc07c Mon Sep 17 00:00:00 2001 From: wujing Date: Wed, 23 Sep 2020 09:51:25 +0800 Subject: [PATCH] iSulad: fix some memory bugs Signed-off-by: wujing --- 0011-iSulad-fix-memory-leak.patch | 53 +++++++++++++++++++ ...ix-coredump-when-load-image-with-uid.patch | 32 +++++++++++ iSulad.spec | 10 +++- update-version.bash | 2 +- 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 0011-iSulad-fix-memory-leak.patch create mode 100644 0012-fix-coredump-when-load-image-with-uid.patch diff --git a/0011-iSulad-fix-memory-leak.patch b/0011-iSulad-fix-memory-leak.patch new file mode 100644 index 0000000..42886c0 --- /dev/null +++ b/0011-iSulad-fix-memory-leak.patch @@ -0,0 +1,53 @@ +From 32c7b484da4e5546d28bc5d88866fa018a0df647 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Tue, 22 Sep 2020 15:29:00 +0800 +Subject: [PATCH 1/2] iSulad: fix memory leak + +Signed-off-by: zhangxiaoyu +--- + src/daemon/modules/image/oci/storage/storage.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/daemon/modules/image/oci/storage/storage.c b/src/daemon/modules/image/oci/storage/storage.c +index 8ad96d60..249aa1b3 100644 +--- a/src/daemon/modules/image/oci/storage/storage.c ++++ b/src/daemon/modules/image/oci/storage/storage.c +@@ -103,15 +103,14 @@ static int fill_read_wrapper(const char *layer_data_path, struct io_read_wrapper + reader_tmp = util_common_calloc_s(sizeof(struct io_read_wrapper)); + if (reader_tmp == NULL) { + ERROR("Memory out"); +- ret = -1; +- goto out; ++ return -1; + } + + fd_ptr = util_common_calloc_s(sizeof(int)); + if (fd_ptr == NULL) { + ERROR("Memory out"); + ret = -1; +- goto out; ++ goto err_out; + } + + *fd_ptr = util_open(layer_data_path, O_RDONLY, 0); +@@ -125,13 +124,14 @@ static int fill_read_wrapper(const char *layer_data_path, struct io_read_wrapper + reader_tmp->read = layer_archive_io_read; + reader_tmp->close = layer_archive_io_close; + *reader = reader_tmp; +- +- goto out; ++ ++ fd_ptr = NULL; ++ reader_tmp = NULL; + + err_out: + free(fd_ptr); + free(reader_tmp); +-out: ++ + return ret; + } + +-- +2.25.1 + diff --git a/0012-fix-coredump-when-load-image-with-uid.patch b/0012-fix-coredump-when-load-image-with-uid.patch new file mode 100644 index 0000000..744e394 --- /dev/null +++ b/0012-fix-coredump-when-load-image-with-uid.patch @@ -0,0 +1,32 @@ +From 514f43054196785e2d40b51592e6691616938f69 Mon Sep 17 00:00:00 2001 +From: wujing +Date: Tue, 22 Sep 2020 16:22:01 +0800 +Subject: [PATCH 2/2] fix coredump when load image with uid + +Signed-off-by: wujing +--- + .../modules/image/oci/storage/image_store/image_store.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/daemon/modules/image/oci/storage/image_store/image_store.c b/src/daemon/modules/image/oci/storage/image_store/image_store.c +index 2d2136ed..f6dd1ef1 100644 +--- a/src/daemon/modules/image/oci/storage/image_store/image_store.c ++++ b/src/daemon/modules/image/oci/storage/image_store/image_store.c +@@ -3119,6 +3119,14 @@ static int pack_user_info_from_image(const docker_image_config_v2 *config_v2, im + goto out; + } + if (util_safe_llong(user, &converted) == 0) { ++ if (info->uid == NULL) { ++ info->uid = (imagetool_image_uid *)util_common_calloc_s(sizeof(imagetool_image_uid)); ++ if (info->uid == NULL) { ++ ERROR("Out of memory"); ++ ret = -1; ++ goto out; ++ } ++ } + info->uid->value = (int64_t)converted; + } else { + info->username = util_strdup_s(user); +-- +2.25.1 + diff --git a/iSulad.spec b/iSulad.spec index 00b12e1..dbe32e8 100644 --- a/iSulad.spec +++ b/iSulad.spec @@ -1,5 +1,5 @@ %global _version 2.0.5 -%global _release 20200918.112827.git9aea9b75 +%global _release 20200923.094914.git05e545f7 %global is_systemd 1 Name: iSulad @@ -23,6 +23,8 @@ Patch6007: 0007-image-clear-memory-if-failed.patch Patch6008: 0008-fix-layer-remain-caused-by-hold-flag-not-clean.patch Patch6009: 0009-fix-coredump-when-pull-image-with-lock-driver-image-.patch Patch6010: 0010-fix-bad-formatting-placeholder-in-http-parse-module.patch +Patch6011: 0011-iSulad-fix-memory-leak.patch +Patch6012: 0012-fix-coredump-when-load-image-with-uid.patch %ifarch x86_64 aarch64 Provides: libhttpclient.so()(64bit) @@ -230,6 +232,12 @@ fi %endif %changelog ++* Fri Sep 23 2020 - 2.0.5-20200923.094914.git05e545f7 ++- Type:bugfix ++- ID:NA ++- SUG:NA ++- DESC: fix some memory bugs + +* Fri Sep 18 2020 - 2.0.5-20200918.112827.git9aea9b75 +- Type:bugfix +- ID:NA diff --git a/update-version.bash b/update-version.bash index 9371461..e13bb84 100755 --- a/update-version.bash +++ b/update-version.bash @@ -24,7 +24,7 @@ first_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {' second_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'} | awk -F "." {'print $2'}) third_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'} | awk -F "." {'print $3'}) read -p "Which level version do you want to upgrade?[1/2/3/d/N](default:N) select:" choice -if [[ ! -n "${choice}" || ${choice} == "N" ]]; then +if [[ ! -n "${choice}" ]] || [[ ${choice} == "N" ]]; then echo "The version number has not been modified, it is still ${old_version}" exit 0 fi