From 2db6add74c621344e902ce28b5e6764f6ef55b8e Mon Sep 17 00:00:00 2001 From: zhongtao Date: Mon, 18 Dec 2023 16:07:57 +0800 Subject: [PATCH 63/64] code improve for oci_rmi Signed-off-by: zhongtao --- src/daemon/modules/image/oci/oci_image.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/daemon/modules/image/oci/oci_image.c b/src/daemon/modules/image/oci/oci_image.c index 471510e7..9cf2cd4f 100644 --- a/src/daemon/modules/image/oci/oci_image.c +++ b/src/daemon/modules/image/oci/oci_image.c @@ -542,6 +542,17 @@ int oci_rmi(const im_rmi_request *request) goto out; } + for (i = 0; i < image_names_len; i++) { + if (strcmp(real_image_name, image_names[i]) == 0) { + break; + } + } + if (i == image_names_len) { + ERROR("Invalid real_image_name"); + ret = -1; + goto out; + } + reduced_image_names = (char **)util_smart_calloc_s(sizeof(char *), image_names_len - 1); if (reduced_image_names == NULL) { ERROR("Out of memory"); -- 2.42.0