From bc194a04b5ae40ef900e167d19b9ae0860bcc096 Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Wed, 30 Aug 2023 10:05:52 +0000
Subject: [PATCH 129/145] !2160 Fix nullptr in src/daemon/entry * Fix nullptr
 in src/daemon/entry

---
 .../connect/grpc/grpc_containers_service.cc   | 130 ++++++++++++++++++
 .../entry/connect/grpc/grpc_images_service.cc |  40 ++++++
 .../connect/grpc/grpc_server_tls_auth.cc      |   4 +
 .../connect/grpc/grpc_volumes_service.cc      |  15 ++
 .../connect/grpc/runtime_image_service.cc     |  29 +++-
 .../connect/grpc/runtime_runtime_service.cc   | 109 ++++++++++++++-
 .../entry/connect/rest/rest_service_common.c  |  12 +-
 .../entry/cri/cri_container_manager_service.h |   4 +-
 .../cri/cri_container_manager_service_impl.cc |  18 +--
 .../cri/cri_container_manager_service_impl.h  |   8 +-
 .../entry/cri/cri_image_manager_service.h     |   4 +-
 .../cri/cri_image_manager_service_impl.cc     |  12 +-
 .../cri/cri_image_manager_service_impl.h      |   8 +-
 src/daemon/entry/cri/cri_runtime_service.h    |   4 +-
 .../entry/cri/cri_runtime_service_impl.cc     |   4 +-
 .../entry/cri/cri_runtime_service_impl.h      |   4 +-
 src/daemon/entry/cri/network_plugin.h         |  10 +-
 17 files changed, 370 insertions(+), 45 deletions(-)

diff --git a/src/daemon/entry/connect/grpc/grpc_containers_service.cc b/src/daemon/entry/connect/grpc/grpc_containers_service.cc
index ab762853..c31137bf 100644
--- a/src/daemon/entry/connect/grpc/grpc_containers_service.cc
+++ b/src/daemon/entry/connect/grpc/grpc_containers_service.cc
@@ -154,6 +154,11 @@ Status ContainerServiceImpl::Version(ServerContext *context, const VersionReques
     container_version_request *container_req = nullptr;
     container_version_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "VersionOp");
 
     auto status = GrpcServerTlsAuth::auth(context, "docker_version");
@@ -188,6 +193,11 @@ Status ContainerServiceImpl::Info(ServerContext *context, const InfoRequest *req
     host_info_request *container_req = nullptr;
     host_info_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "InfoOp");
 
     auto status = GrpcServerTlsAuth::auth(context, "docker_info");
@@ -222,6 +232,11 @@ Status ContainerServiceImpl::Create(ServerContext *context, const CreateRequest
     container_create_response *container_res = nullptr;
     container_create_request *container_req = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContCreate");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_create");
@@ -256,6 +271,11 @@ Status ContainerServiceImpl::Start(ServerContext *context, const StartRequest *r
     container_start_request *req = nullptr;
     container_start_response *res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContStart");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_start");
@@ -414,6 +434,11 @@ Status ContainerServiceImpl::Top(ServerContext *context, const TopRequest *reque
     container_top_request *req = nullptr;
     container_top_response *res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContTop");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_top");
@@ -448,6 +473,11 @@ Status ContainerServiceImpl::Stop(ServerContext *context, const StopRequest *req
     container_stop_request *container_req = nullptr;
     container_stop_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContStop");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_stop");
@@ -483,6 +513,11 @@ Status ContainerServiceImpl::Restart(ServerContext *context, const RestartReques
     container_restart_request *container_req = nullptr;
     container_restart_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContRestart");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_restart");
@@ -517,6 +552,11 @@ Status ContainerServiceImpl::Kill(ServerContext *context, const KillRequest *req
     container_kill_request *container_req = nullptr;
     container_kill_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContKill");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_kill");
@@ -551,6 +591,11 @@ Status ContainerServiceImpl::Delete(ServerContext *context, const DeleteRequest
     container_delete_request *container_req = nullptr;
     container_delete_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContDelete");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_delete");
@@ -585,6 +630,11 @@ Status ContainerServiceImpl::Exec(ServerContext *context, const ExecRequest *req
     container_exec_request *container_req = nullptr;
     container_exec_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContExec");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_exec_create");
@@ -691,6 +741,11 @@ Status ContainerServiceImpl::RemoteExec(ServerContext *context,
     container_exec_request *container_req = nullptr;
     container_exec_response *container_res = nullptr;
 
+    if (context == nullptr || stream == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContRExec");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_exec_create");
@@ -767,6 +822,11 @@ Status ContainerServiceImpl::Inspect(ServerContext *context, const InspectContai
     container_inspect_request *container_req = nullptr;
     container_inspect_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContInspect");
 
     Status status = GrpcServerTlsAuth::auth(context, "container_inspect");
@@ -802,6 +862,11 @@ Status ContainerServiceImpl::List(ServerContext *context, const ListRequest *req
     container_list_request *container_req = nullptr;
     container_list_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContList");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_list");
@@ -916,6 +981,11 @@ Status ContainerServiceImpl::Attach(ServerContext *context, ServerReaderWriter<A
     sem_t sem_stderr;
     int pipefd[2] = { -1, -1 };
 
+    if (context == nullptr || stream == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContAttach");
 
     auto status = AttachInit(context, &cb, &container_req, &container_res, &sem_stderr, pipefd);
@@ -979,6 +1049,11 @@ Status ContainerServiceImpl::Pause(ServerContext *context, const PauseRequest *r
     container_pause_request *container_req = nullptr;
     container_pause_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContPause");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_pause");
@@ -1013,6 +1088,11 @@ Status ContainerServiceImpl::Resume(ServerContext *context, const ResumeRequest
     container_resume_request *container_req = nullptr;
     container_resume_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContResume");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_unpause");
@@ -1047,6 +1127,11 @@ Status ContainerServiceImpl::Export(ServerContext *context, const ExportRequest
     container_export_request *container_req = nullptr;
     container_export_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContExport");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_export");
@@ -1081,6 +1166,11 @@ Status ContainerServiceImpl::Rename(ServerContext *context, const RenameRequest
     struct isulad_container_rename_request *isuladreq = nullptr;
     struct isulad_container_rename_response *isuladres = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContRename");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_rename");
@@ -1116,6 +1206,11 @@ Status ContainerServiceImpl::Resize(ServerContext *context, const ResizeRequest
     struct isulad_container_resize_request *isuladreq = nullptr;
     struct isulad_container_resize_response *isuladres = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContResize");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_resize");
@@ -1151,6 +1246,11 @@ Status ContainerServiceImpl::Update(ServerContext *context, const UpdateRequest
     container_update_request *container_req = nullptr;
     container_update_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContUpdate");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_update");
@@ -1185,6 +1285,11 @@ Status ContainerServiceImpl::Stats(ServerContext *context, const StatsRequest *r
     container_stats_request *container_req = nullptr;
     container_stats_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContStats");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_stats");
@@ -1219,6 +1324,11 @@ Status ContainerServiceImpl::Wait(ServerContext *context, const WaitRequest *req
     container_wait_request *container_req = nullptr;
     container_wait_response *container_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContWait");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_wait");
@@ -1253,6 +1363,11 @@ Status ContainerServiceImpl::Events(ServerContext *context, const EventsRequest
     isulad_events_request *isuladreq = nullptr;
     stream_func_wrapper stream = { 0 };
 
+    if (context == nullptr || request == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContEvents");
 
     auto status = GrpcServerTlsAuth::auth(context, "docker_events");
@@ -1291,6 +1406,11 @@ Status ContainerServiceImpl::CopyFromContainer(ServerContext *context, const Cop
     service_executor_t *cb = nullptr;
     isulad_copy_from_container_request *isuladreq = nullptr;
 
+    if (context == nullptr || request == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContCopyFrom");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_archive");
@@ -1335,6 +1455,11 @@ ContainerServiceImpl::CopyToContainer(ServerContext *context,
     service_executor_t *cb = nullptr;
     container_copy_to_request *isuladreq = nullptr;
 
+    if (context == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContCopyTo");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_archive");
@@ -1444,6 +1569,11 @@ Status ContainerServiceImpl::Logs(ServerContext *context, const LogsRequest *req
     struct isulad_logs_response *isulad_response = nullptr;
     stream_func_wrapper stream = { 0 };
 
+    if (context == nullptr || request == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ContLogs");
 
     auto status = GrpcServerTlsAuth::auth(context, "container_logs");
diff --git a/src/daemon/entry/connect/grpc/grpc_images_service.cc b/src/daemon/entry/connect/grpc/grpc_images_service.cc
index f078711e..678f37ad 100644
--- a/src/daemon/entry/connect/grpc/grpc_images_service.cc
+++ b/src/daemon/entry/connect/grpc/grpc_images_service.cc
@@ -243,6 +243,11 @@ void ImagesServiceImpl::inspect_response_to_grpc(const image_inspect_response *r
 
 Status ImagesServiceImpl::List(ServerContext *context, const ListImagesRequest *request, ListImagesResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ImageList");
 
     auto status = GrpcServerTlsAuth::auth(context, "image_list");
@@ -274,6 +279,11 @@ Status ImagesServiceImpl::List(ServerContext *context, const ListImagesRequest *
 
 Status ImagesServiceImpl::Delete(ServerContext *context, const DeleteImageRequest *request, DeleteImageResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ImageDelete");
 
     auto status = GrpcServerTlsAuth::auth(context, "image_delete");
@@ -305,6 +315,11 @@ Status ImagesServiceImpl::Delete(ServerContext *context, const DeleteImageReques
 
 Status ImagesServiceImpl::Tag(ServerContext *context, const TagImageRequest *request, TagImageResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ImageTag");
 
     auto status = GrpcServerTlsAuth::auth(context, "image_tag");
@@ -352,6 +367,11 @@ void ImagesServiceImpl::import_response_to_grpc(const image_import_response *res
 
 Status ImagesServiceImpl::Import(ServerContext *context, const ImportRequest *request, ImportResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ImageImport");
 
     auto status = GrpcServerTlsAuth::auth(context, "image_import");
@@ -383,6 +403,11 @@ Status ImagesServiceImpl::Import(ServerContext *context, const ImportRequest *re
 
 Status ImagesServiceImpl::Load(ServerContext *context, const LoadImageRequest *request, LoadImageResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ImageLoad");
 
     auto status = GrpcServerTlsAuth::auth(context, "image_load");
@@ -420,6 +445,11 @@ Status ImagesServiceImpl::Inspect(ServerContext *context, const InspectImageRequ
     image_inspect_request *image_req = nullptr;
     image_inspect_response *image_res = nullptr;
 
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "ImageInspect");
 
     Status status = GrpcServerTlsAuth::auth(context, "image_inspect");
@@ -494,6 +524,11 @@ int ImagesServiceImpl::image_logout_request_from_grpc(const LogoutRequest *grequ
 
 Status ImagesServiceImpl::Login(ServerContext *context, const LoginRequest *request, LoginResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "RegistryLogin");
 
     auto status = GrpcServerTlsAuth::auth(context, "login");
@@ -527,6 +562,11 @@ Status ImagesServiceImpl::Login(ServerContext *context, const LoginRequest *requ
 
 Status ImagesServiceImpl::Logout(ServerContext *context, const LogoutRequest *request, LogoutResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     prctl(PR_SET_NAME, "RegistryLogout");
 
     auto status = GrpcServerTlsAuth::auth(context, "logout");
diff --git a/src/daemon/entry/connect/grpc/grpc_server_tls_auth.cc b/src/daemon/entry/connect/grpc/grpc_server_tls_auth.cc
index 968a6dfe..2656a9bf 100644
--- a/src/daemon/entry/connect/grpc/grpc_server_tls_auth.cc
+++ b/src/daemon/entry/connect/grpc/grpc_server_tls_auth.cc
@@ -27,6 +27,10 @@ namespace GrpcServerTlsAuth {
 Status auth(ServerContext *context, const std::string &action)
 {
 #ifdef ENABLE_GRPC_REMOTE_CONNECT
+    if (context == nullptr) {
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     const std::multimap<grpc::string_ref, grpc::string_ref> &init_metadata = context->client_metadata();
     auto tls_mode_kv = init_metadata.find("tls_mode");
     if (tls_mode_kv == init_metadata.end()) {
diff --git a/src/daemon/entry/connect/grpc/grpc_volumes_service.cc b/src/daemon/entry/connect/grpc/grpc_volumes_service.cc
index 8b090486..004b57b2 100644
--- a/src/daemon/entry/connect/grpc/grpc_volumes_service.cc
+++ b/src/daemon/entry/connect/grpc/grpc_volumes_service.cc
@@ -118,6 +118,11 @@ int VolumeServiceImpl::volume_prune_response_to_grpc(volume_prune_volume_respons
 
 Status VolumeServiceImpl::List(ServerContext *context, const ListVolumeRequest *request, ListVolumeResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     auto status = GrpcServerTlsAuth::auth(context, "volume_list");
     if (!status.ok()) {
         return status;
@@ -152,6 +157,11 @@ Status VolumeServiceImpl::List(ServerContext *context, const ListVolumeRequest *
 Status VolumeServiceImpl::Remove(ServerContext *context, const RemoveVolumeRequest *request,
                                  RemoveVolumeResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     auto status = GrpcServerTlsAuth::auth(context, "volume_remove");
     if (!status.ok()) {
         return status;
@@ -185,6 +195,11 @@ Status VolumeServiceImpl::Remove(ServerContext *context, const RemoveVolumeReque
 
 Status VolumeServiceImpl::Prune(ServerContext *context, const PruneVolumeRequest *request, PruneVolumeResponse *reply)
 {
+    if (context == nullptr || request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return Status(StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     auto status = GrpcServerTlsAuth::auth(context, "volume_prune");
     if (!status.ok()) {
         return status;
diff --git a/src/daemon/entry/connect/grpc/runtime_image_service.cc b/src/daemon/entry/connect/grpc/runtime_image_service.cc
index e593a9c6..602e46fd 100644
--- a/src/daemon/entry/connect/grpc/runtime_image_service.cc
+++ b/src/daemon/entry/connect/grpc/runtime_image_service.cc
@@ -33,6 +33,11 @@ grpc::Status RuntimeImageServiceImpl::PullImage(grpc::ServerContext *context,
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Pulling image %s}", request->image().image().c_str());
 
     std::string imageRef = rService->PullImage(request->image(), request->auth(), error);
@@ -54,9 +59,14 @@ grpc::Status RuntimeImageServiceImpl::ListImages(grpc::ServerContext *context,
     std::vector<std::unique_ptr<runtime::v1alpha2::Image>> images;
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Listing all images}");
 
-    rService->ListImages(request->filter(), &images, error);
+    rService->ListImages(request->filter(), images, error);
     if (!error.Empty()) {
         ERROR("{Object: CRI, Type: Failed to list all images: %s}", error.GetMessage().c_str());
         return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
@@ -82,6 +92,11 @@ grpc::Status RuntimeImageServiceImpl::ImageStatus(grpc::ServerContext *context,
     std::unique_ptr<runtime::v1alpha2::Image> image_info = nullptr;
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Statusing image %s}", request->image().image().c_str());
 
     image_info = rService->ImageStatus(request->image(), error);
@@ -108,9 +123,14 @@ grpc::Status RuntimeImageServiceImpl::ImageFsInfo(grpc::ServerContext *context,
     std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> usages;
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Statusing image fs info}");
 
-    rService->ImageFsInfo(&usages, error);
+    rService->ImageFsInfo(usages, error);
     if (!error.Empty()) {
         ERROR("{Object: CRI, Type: Failed to status image fs info: %s}", error.GetMessage().c_str());
         return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
@@ -135,6 +155,11 @@ grpc::Status RuntimeImageServiceImpl::RemoveImage(grpc::ServerContext *context,
 {
     Errors error;
 
+    if (request == nullptr) {
+        ERROR("Invalid arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Removing image %s}", request->image().image().c_str());
 
     rService->RemoveImage(request->image(), error);
diff --git a/src/daemon/entry/connect/grpc/runtime_runtime_service.cc b/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
index 451eeeef..852d6791 100644
--- a/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
+++ b/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
@@ -31,6 +31,11 @@ using namespace CRI;
 void RuntimeRuntimeServiceImpl::Init(Network::NetworkPluginConf mConf, isulad_daemon_configs *config, Errors &err)
 {
     std::string podSandboxImage;
+    if (config == nullptr) {
+        err.SetError("Invalid input arguments");
+        ERROR("Invalid input arguments");
+        return;
+    }
     if (config->pod_sandbox_image != nullptr) {
         podSandboxImage = config->pod_sandbox_image;
     } else {
@@ -89,6 +94,11 @@ grpc::Status RuntimeRuntimeServiceImpl::Version(grpc::ServerContext *context,
                                                 runtime::v1alpha2::VersionResponse *reply)
 {
     Errors error;
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     rService->Version(request->version(), reply, error);
     if (!error.Empty()) {
         return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
@@ -103,6 +113,11 @@ grpc::Status RuntimeRuntimeServiceImpl::CreateContainer(grpc::ServerContext *con
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Creating Container}");
 
     std::string responseID =
@@ -124,6 +139,11 @@ grpc::Status RuntimeRuntimeServiceImpl::StartContainer(grpc::ServerContext *cont
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Starting Container: %s}", request->container_id().c_str());
 
     rService->StartContainer(request->container_id(), error);
@@ -143,6 +163,11 @@ grpc::Status RuntimeRuntimeServiceImpl::StopContainer(grpc::ServerContext *conte
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Stopping Container: %s}", request->container_id().c_str());
 
     rService->StopContainer(request->container_id(), (int64_t)request->timeout(), error);
@@ -162,6 +187,11 @@ grpc::Status RuntimeRuntimeServiceImpl::RemoveContainer(grpc::ServerContext *con
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Removing Container: %s}", request->container_id().c_str());
 
     rService->RemoveContainer(request->container_id(), error);
@@ -181,10 +211,15 @@ grpc::Status RuntimeRuntimeServiceImpl::ListContainers(grpc::ServerContext *cont
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Listing all Container}");
 
     std::vector<std::unique_ptr<runtime::v1alpha2::Container>> containers;
-    rService->ListContainers(request->has_filter() ? &request->filter() : nullptr, &containers, error);
+    rService->ListContainers(request->has_filter() ? &request->filter() : nullptr, containers, error);
     if (!error.Empty()) {
         ERROR("Object: CRI, Type: Failed to list all containers %s", error.GetMessage().c_str());
         return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
@@ -210,10 +245,15 @@ grpc::Status RuntimeRuntimeServiceImpl::ListContainerStats(grpc::ServerContext *
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Listing all Container stats}");
 
     std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> containers;
-    rService->ListContainerStats(request->has_filter() ? &request->filter() : nullptr, &containers, error);
+    rService->ListContainerStats(request->has_filter() ? &request->filter() : nullptr, containers, error);
     if (!error.Empty()) {
         ERROR("Object: CRI, Type: Failed to list all containers stat %s", error.GetMessage().c_str());
         return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
@@ -239,6 +279,11 @@ grpc::Status RuntimeRuntimeServiceImpl::ContainerStats(grpc::ServerContext *cont
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Getting Container Stats: %s}", request->container_id().c_str());
 
     std::unique_ptr<runtime::v1alpha2::ContainerStats> contStats =
@@ -260,6 +305,11 @@ grpc::Status RuntimeRuntimeServiceImpl::ContainerStatus(grpc::ServerContext *con
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Statusing Container: %s}", request->container_id().c_str());
 
     std::unique_ptr<runtime::v1alpha2::ContainerStatus> contStatus =
@@ -281,6 +331,11 @@ grpc::Status RuntimeRuntimeServiceImpl::ExecSync(grpc::ServerContext *context,
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     WARN("Event: {Object: CRI, Type: sync execing Container: %s}", request->container_id().c_str());
 
     rService->ExecSync(request->container_id(), request->cmd(), request->timeout(), reply, error);
@@ -300,6 +355,11 @@ grpc::Status RuntimeRuntimeServiceImpl::RunPodSandbox(grpc::ServerContext *conte
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Running Pod}");
 
     std::string responseID = rService->RunPodSandbox(request->config(), request->runtime_handler(), error);
@@ -320,6 +380,11 @@ grpc::Status RuntimeRuntimeServiceImpl::StopPodSandbox(grpc::ServerContext *cont
 {
     Errors error;
 
+    if (request == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Stopping Pod: %s}", request->pod_sandbox_id().c_str());
 
     rService->StopPodSandbox(request->pod_sandbox_id(), error);
@@ -340,6 +405,11 @@ grpc::Status RuntimeRuntimeServiceImpl::RemovePodSandbox(grpc::ServerContext *co
 {
     Errors error;
 
+    if (request == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Removing Pod: %s}", request->pod_sandbox_id().c_str());
 
     rService->RemovePodSandbox(request->pod_sandbox_id(), error);
@@ -360,6 +430,11 @@ grpc::Status RuntimeRuntimeServiceImpl::PodSandboxStatus(grpc::ServerContext *co
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Status Pod: %s}", request->pod_sandbox_id().c_str());
 
     std::unique_ptr<runtime::v1alpha2::PodSandboxStatus> podStatus;
@@ -382,6 +457,11 @@ grpc::Status RuntimeRuntimeServiceImpl::ListPodSandbox(grpc::ServerContext *cont
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Listing all Pods}");
 
     std::vector<std::unique_ptr<runtime::v1alpha2::PodSandbox>> pods;
@@ -411,6 +491,11 @@ RuntimeRuntimeServiceImpl::UpdateContainerResources(grpc::ServerContext *context
 {
     Errors error;
 
+    if (request == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     WARN("Event: {Object: CRI, Type: Updating container resources: %s}", request->container_id().c_str());
 
     rService->UpdateContainerResources(request->container_id(), request->linux(), error);
@@ -431,6 +516,11 @@ grpc::Status RuntimeRuntimeServiceImpl::Exec(grpc::ServerContext *context,
 {
     Errors error;
 
+    if (request == nullptr || response == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: execing Container: %s}", request->container_id().c_str());
 
     rService->Exec(*request, response, error);
@@ -451,6 +541,11 @@ grpc::Status RuntimeRuntimeServiceImpl::Attach(grpc::ServerContext *context,
 {
     Errors error;
 
+    if (request == nullptr || response == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: attaching Container: %s}", request->container_id().c_str());
 
     rService->Attach(*request, response, error);
@@ -472,6 +567,11 @@ RuntimeRuntimeServiceImpl::UpdateRuntimeConfig(grpc::ServerContext *context,
 {
     Errors error;
 
+    if (request == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     EVENT("Event: {Object: CRI, Type: Updating Runtime Config}");
 
     rService->UpdateRuntimeConfig(request->runtime_config(), error);
@@ -491,6 +591,11 @@ grpc::Status RuntimeRuntimeServiceImpl::Status(grpc::ServerContext *context,
 {
     Errors error;
 
+    if (request == nullptr || reply == nullptr) {
+        ERROR("Invalid input arguments");
+        return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
+    }
+
     INFO("Event: {Object: CRI, Type: Statusing daemon}");
 
     std::unique_ptr<runtime::v1alpha2::RuntimeStatus> status = rService->Status(error);
diff --git a/src/daemon/entry/connect/rest/rest_service_common.c b/src/daemon/entry/connect/rest/rest_service_common.c
index 54ac5c95..c4161d02 100644
--- a/src/daemon/entry/connect/rest/rest_service_common.c
+++ b/src/daemon/entry/connect/rest/rest_service_common.c
@@ -26,7 +26,7 @@
 /* get body */
 int get_body(const evhtp_request_t *req, size_t *size_out, char **record_out)
 {
-    evbuf_t *buf = req->buffer_in;
+    evbuf_t *buf = NULL;
     size_t read_count = 0;
     size_t total = 0;
     size_t content_len = 0;
@@ -34,6 +34,12 @@ int get_body(const evhtp_request_t *req, size_t *size_out, char **record_out)
     char *body_p = NULL;
     int ret = 0;
 
+    if (req == NULL || size_out == NULL || record_out == NULL) {
+        ERROR("Invalid input arguments");
+        return -1;
+    }
+
+    buf = req->buffer_in;
     content_len = (size_t)evbuffer_get_length(buf);
 
     if (content_len >= MAX_BODY_SIZE) {
@@ -81,6 +87,10 @@ empty:
 /* evhtp send repsponse */
 void evhtp_send_response(evhtp_request_t *req, const char *responsedata, int rescode)
 {
+    if (req == NULL || responsedata == NULL) {
+        ERROR("Invalid input arguments");
+        return;
+    }
     evhtp_headers_add_header(req->headers_out, evhtp_header_new("Content-Type", "application/json", 0, 0));
     evbuffer_add(req->buffer_out, responsedata, strlen(responsedata));
     evhtp_send_reply(req, rescode);
diff --git a/src/daemon/entry/cri/cri_container_manager_service.h b/src/daemon/entry/cri/cri_container_manager_service.h
index f362f798..b235913b 100644
--- a/src/daemon/entry/cri/cri_container_manager_service.h
+++ b/src/daemon/entry/cri/cri_container_manager_service.h
@@ -39,11 +39,11 @@ public:
     virtual void RemoveContainer(const std::string &containerID, Errors &error) = 0;
 
     virtual void ListContainers(const runtime::v1alpha2::ContainerFilter *filter,
-                                std::vector<std::unique_ptr<runtime::v1alpha2::Container>> *containers,
+                                std::vector<std::unique_ptr<runtime::v1alpha2::Container>> &containers,
                                 Errors &error) = 0;
 
     virtual void ListContainerStats(const runtime::v1alpha2::ContainerStatsFilter *filter,
-                                    std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> *containerstats,
+                                    std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> &containerstats,
                                     Errors &error) = 0;
 
     virtual auto ContainerStats(const std::string &containerID,
diff --git a/src/daemon/entry/cri/cri_container_manager_service_impl.cc b/src/daemon/entry/cri/cri_container_manager_service_impl.cc
index ed9e8e72..c358c934 100644
--- a/src/daemon/entry/cri/cri_container_manager_service_impl.cc
+++ b/src/daemon/entry/cri/cri_container_manager_service_impl.cc
@@ -667,7 +667,7 @@ void ContainerManagerServiceImpl::ListContainersFromGRPC(const runtime::v1alpha2
 }
 
 void ContainerManagerServiceImpl::ListContainersToGRPC(container_list_response *response,
-                                                       std::vector<std::unique_ptr<runtime::v1alpha2::Container>> *pods,
+                                                       std::vector<std::unique_ptr<runtime::v1alpha2::Container>> &pods,
                                                        Errors &error)
 {
     for (size_t i {}; i < response->containers_len; i++) {
@@ -714,12 +714,12 @@ void ContainerManagerServiceImpl::ListContainersToGRPC(container_list_response *
             CRIHelpers::ContainerStatusToRuntime(Container_Status(response->containers[i]->status));
         container->set_state(state);
 
-        pods->push_back(move(container));
+        pods.push_back(move(container));
     }
 }
 
 void ContainerManagerServiceImpl::ListContainers(const runtime::v1alpha2::ContainerFilter *filter,
-                                                 std::vector<std::unique_ptr<runtime::v1alpha2::Container>> *containers,
+                                                 std::vector<std::unique_ptr<runtime::v1alpha2::Container>> &containers,
                                                  Errors &error)
 {
     if (m_cb == nullptr || m_cb->container.list == nullptr) {
@@ -870,7 +870,7 @@ void ContainerManagerServiceImpl::PackContainerStatsFilesystemUsage(
 
 void ContainerManagerServiceImpl::ContainerStatsToGRPC(
     container_stats_response *response,
-    std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> *containerstats, Errors &error)
+    std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> &containerstats, Errors &error)
 {
     if (response == nullptr) {
         return;
@@ -907,22 +907,18 @@ void ContainerManagerServiceImpl::ContainerStatsToGRPC(
             container->mutable_cpu()->set_timestamp(timestamp);
         }
 
-        containerstats->push_back(move(container));
+        containerstats.push_back(move(container));
     }
 }
 
 void ContainerManagerServiceImpl::ListContainerStats(
     const runtime::v1alpha2::ContainerStatsFilter *filter,
-    std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> *containerstats, Errors &error)
+    std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> &containerstats, Errors &error)
 {
     if (m_cb == nullptr || m_cb->container.stats == nullptr) {
         error.SetError("Unimplemented callback");
         return;
     }
-    if (containerstats == nullptr) {
-        error.SetError("Invalid arguments");
-        return;
-    }
 
     container_stats_response *response { nullptr };
     container_stats_request *request = (container_stats_request *)util_common_calloc_s(sizeof(container_stats_request));
@@ -999,7 +995,7 @@ auto ContainerManagerServiceImpl::ContainerStats(const std::string &containerID,
         goto cleanup;
     }
 
-    ContainerStatsToGRPC(response, &contStatsVec, error);
+    ContainerStatsToGRPC(response, contStatsVec, error);
     if (error.NotEmpty()) {
         goto cleanup;
     }
diff --git a/src/daemon/entry/cri/cri_container_manager_service_impl.h b/src/daemon/entry/cri/cri_container_manager_service_impl.h
index ad53a65f..32f07456 100644
--- a/src/daemon/entry/cri/cri_container_manager_service_impl.h
+++ b/src/daemon/entry/cri/cri_container_manager_service_impl.h
@@ -49,11 +49,11 @@ public:
     void RemoveContainer(const std::string &containerID, Errors &error) override;
 
     void ListContainers(const runtime::v1alpha2::ContainerFilter *filter,
-                        std::vector<std::unique_ptr<runtime::v1alpha2::Container>> *containers,
+                        std::vector<std::unique_ptr<runtime::v1alpha2::Container>> &containers,
                         Errors &error) override;
 
     void ListContainerStats(const runtime::v1alpha2::ContainerStatsFilter *filter,
-                            std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> *containerstats,
+                            std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> &containerstats,
                             Errors &error) override;
 
     auto ContainerStats(const std::string &containerID,
@@ -102,11 +102,11 @@ private:
     void ListContainersFromGRPC(const runtime::v1alpha2::ContainerFilter *filter, container_list_request **request,
                                 Errors &error);
     void ListContainersToGRPC(container_list_response *response,
-                              std::vector<std::unique_ptr<runtime::v1alpha2::Container>> *pods, Errors &error);
+                              std::vector<std::unique_ptr<runtime::v1alpha2::Container>> &pods, Errors &error);
     auto PackContainerStatsFilter(const runtime::v1alpha2::ContainerStatsFilter *filter,
                                   container_stats_request *request, Errors &error) -> int;
     void ContainerStatsToGRPC(container_stats_response *response,
-                              std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> *containerstats,
+                              std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> &containerstats,
                               Errors &error);
     void PackContainerStatsAttributes(const char *id, std::unique_ptr<runtime::v1alpha2::ContainerStats> &container,
                                       Errors &error);
diff --git a/src/daemon/entry/cri/cri_image_manager_service.h b/src/daemon/entry/cri/cri_image_manager_service.h
index b6e506d5..9b2530ab 100644
--- a/src/daemon/entry/cri/cri_image_manager_service.h
+++ b/src/daemon/entry/cri/cri_image_manager_service.h
@@ -28,7 +28,7 @@ public:
     virtual ~ImageManagerService() = default;
 
     virtual void ListImages(const runtime::v1alpha2::ImageFilter &filter,
-                            std::vector<std::unique_ptr<runtime::v1alpha2::Image>> *images, Errors &error) = 0;
+                            std::vector<std::unique_ptr<runtime::v1alpha2::Image>> &images, Errors &error) = 0;
 
     virtual auto ImageStatus(const runtime::v1alpha2::ImageSpec &image,
                              Errors &error) -> std::unique_ptr<runtime::v1alpha2::Image> = 0;
@@ -38,7 +38,7 @@ public:
 
     virtual void RemoveImage(const runtime::v1alpha2::ImageSpec &image, Errors &error) = 0;
 
-    virtual void ImageFsInfo(std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> *usages,
+    virtual void ImageFsInfo(std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> &usages,
                              Errors &error) = 0;
 };
 } // namespace CRI
diff --git a/src/daemon/entry/cri/cri_image_manager_service_impl.cc b/src/daemon/entry/cri/cri_image_manager_service_impl.cc
index ad9e8ef1..3ff79ffc 100644
--- a/src/daemon/entry/cri/cri_image_manager_service_impl.cc
+++ b/src/daemon/entry/cri/cri_image_manager_service_impl.cc
@@ -133,7 +133,7 @@ auto ImageManagerServiceImpl::list_request_from_grpc(const runtime::v1alpha2::Im
 }
 
 void ImageManagerServiceImpl::list_images_to_grpc(im_list_response *response,
-                                                  std::vector<std::unique_ptr<runtime::v1alpha2::Image>> *images,
+                                                  std::vector<std::unique_ptr<runtime::v1alpha2::Image>> &images,
                                                   Errors &error)
 {
     imagetool_images_list *list_images = response->images;
@@ -150,12 +150,12 @@ void ImageManagerServiceImpl::list_images_to_grpc(im_list_response *response,
 
         imagetool_image_summary *element = list_images->images[i];
         conv_image_to_grpc(element, image);
-        images->push_back(move(image));
+        images.push_back(move(image));
     }
 }
 
 void ImageManagerServiceImpl::ListImages(const runtime::v1alpha2::ImageFilter &filter,
-                                         std::vector<std::unique_ptr<runtime::v1alpha2::Image>> *images, Errors &error)
+                                         std::vector<std::unique_ptr<runtime::v1alpha2::Image>> &images, Errors &error)
 {
     im_list_request *request { nullptr };
     im_list_response *response { nullptr };
@@ -331,7 +331,7 @@ cleanup:
 }
 
 void ImageManagerServiceImpl::fs_info_to_grpc(im_fs_info_response *response,
-                                              std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> *fs_infos,
+                                              std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> &fs_infos,
                                               Errors & /*error*/)
 {
     imagetool_fs_info *got_fs_info = response->fs_info;
@@ -381,11 +381,11 @@ void ImageManagerServiceImpl::fs_info_to_grpc(im_fs_info_response *response,
             fs_info->set_allocated_inodes_used(inodes_used);
         }
 
-        fs_infos->push_back(std::move(fs_info));
+        fs_infos.push_back(std::move(fs_info));
     }
 }
 
-void ImageManagerServiceImpl::ImageFsInfo(std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> *usages,
+void ImageManagerServiceImpl::ImageFsInfo(std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> &usages,
                                           Errors &error)
 {
     im_fs_info_response *response { nullptr };
diff --git a/src/daemon/entry/cri/cri_image_manager_service_impl.h b/src/daemon/entry/cri/cri_image_manager_service_impl.h
index b94f8908..edf482c9 100644
--- a/src/daemon/entry/cri/cri_image_manager_service_impl.h
+++ b/src/daemon/entry/cri/cri_image_manager_service_impl.h
@@ -30,7 +30,7 @@ public:
     virtual ~ImageManagerServiceImpl() = default;
 
     void ListImages(const runtime::v1alpha2::ImageFilter &filter,
-                    std::vector<std::unique_ptr<runtime::v1alpha2::Image>> *images, Errors &error) override;
+                    std::vector<std::unique_ptr<runtime::v1alpha2::Image>> &images, Errors &error) override;
 
     std::unique_ptr<runtime::v1alpha2::Image> ImageStatus(const runtime::v1alpha2::ImageSpec &image,
                                                           Errors &error) override;
@@ -40,7 +40,7 @@ public:
 
     void RemoveImage(const runtime::v1alpha2::ImageSpec &image, Errors &error) override;
 
-    void ImageFsInfo(std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> *usages, Errors &error) override;
+    void ImageFsInfo(std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> &usages, Errors &error) override;
 
 private:
     int pull_request_from_grpc(const runtime::v1alpha2::ImageSpec *image, const runtime::v1alpha2::AuthConfig *auth,
@@ -48,7 +48,7 @@ private:
 
     int list_request_from_grpc(const runtime::v1alpha2::ImageFilter *filter, im_list_request **request, Errors &error);
 
-    void list_images_to_grpc(im_list_response *response, std::vector<std::unique_ptr<runtime::v1alpha2::Image>> *images,
+    void list_images_to_grpc(im_list_response *response, std::vector<std::unique_ptr<runtime::v1alpha2::Image>> &images,
                              Errors &error);
 
     int status_request_from_grpc(const runtime::v1alpha2::ImageSpec *image, im_summary_request **request,
@@ -57,7 +57,7 @@ private:
     std::unique_ptr<runtime::v1alpha2::Image> status_image_to_grpc(im_summary_response *response, Errors &error);
 
     void fs_info_to_grpc(im_fs_info_response *response,
-                         std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> *fs_infos, Errors &error);
+                         std::vector<std::unique_ptr<runtime::v1alpha2::FilesystemUsage>> &fs_infos, Errors &error);
 
     int remove_request_from_grpc(const runtime::v1alpha2::ImageSpec *image, im_rmi_request **request, Errors &error);
 };
diff --git a/src/daemon/entry/cri/cri_runtime_service.h b/src/daemon/entry/cri/cri_runtime_service.h
index 5e4740cb..06674a3f 100644
--- a/src/daemon/entry/cri/cri_runtime_service.h
+++ b/src/daemon/entry/cri/cri_runtime_service.h
@@ -43,10 +43,10 @@ public:
     virtual void RemoveContainer(const std::string &containerID, Errors &error) = 0;
 
     virtual void ListContainers(const runtime::v1alpha2::ContainerFilter *filter,
-                                std::vector<std::unique_ptr<runtime::v1alpha2::Container>> *containers, Errors &error) = 0;
+                                std::vector<std::unique_ptr<runtime::v1alpha2::Container>> &containers, Errors &error) = 0;
 
     virtual void ListContainerStats(const runtime::v1alpha2::ContainerStatsFilter *filter,
-                                    std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> *containerstats,
+                                    std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> &containerstats,
                                     Errors &error) = 0;
 
     virtual auto ContainerStats(const std::string &containerID,
diff --git a/src/daemon/entry/cri/cri_runtime_service_impl.cc b/src/daemon/entry/cri/cri_runtime_service_impl.cc
index e00bc6e2..3da46168 100644
--- a/src/daemon/entry/cri/cri_runtime_service_impl.cc
+++ b/src/daemon/entry/cri/cri_runtime_service_impl.cc
@@ -48,13 +48,13 @@ void CRIRuntimeServiceImpl::RemoveContainer(const std::string &containerID, Erro
 }
 
 void CRIRuntimeServiceImpl::ListContainers(const runtime::v1alpha2::ContainerFilter *filter,
-                                           std::vector<std::unique_ptr<runtime::v1alpha2::Container>> *containers, Errors &error)
+                                           std::vector<std::unique_ptr<runtime::v1alpha2::Container>> &containers, Errors &error)
 {
     m_containerManager->ListContainers(filter, containers, error);
 }
 
 void CRIRuntimeServiceImpl::ListContainerStats(const runtime::v1alpha2::ContainerStatsFilter *filter,
-                                               std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> *containerstats,
+                                               std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> &containerstats,
                                                Errors &error)
 {
     m_containerManager->ListContainerStats(filter, containerstats, error);
diff --git a/src/daemon/entry/cri/cri_runtime_service_impl.h b/src/daemon/entry/cri/cri_runtime_service_impl.h
index 95f1424f..0247c094 100644
--- a/src/daemon/entry/cri/cri_runtime_service_impl.h
+++ b/src/daemon/entry/cri/cri_runtime_service_impl.h
@@ -52,10 +52,10 @@ public:
     void RemoveContainer(const std::string &containerID, Errors &error) override;
 
     void ListContainers(const runtime::v1alpha2::ContainerFilter *filter,
-                        std::vector<std::unique_ptr<runtime::v1alpha2::Container>> *containers, Errors &error) override;
+                        std::vector<std::unique_ptr<runtime::v1alpha2::Container>> &containers, Errors &error) override;
 
     void ListContainerStats(const runtime::v1alpha2::ContainerStatsFilter *filter,
-                            std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> *containerstats,
+                            std::vector<std::unique_ptr<runtime::v1alpha2::ContainerStats>> &containerstats,
                             Errors &error) override;
 
     auto ContainerStats(const std::string &containerID,
diff --git a/src/daemon/entry/cri/network_plugin.h b/src/daemon/entry/cri/network_plugin.h
index 1b06ca73..c29bf248 100644
--- a/src/daemon/entry/cri/network_plugin.h
+++ b/src/daemon/entry/cri/network_plugin.h
@@ -30,11 +30,11 @@ const std::string POD_DISABLE_DEFAULT_NET_ANNOTATION_KEY = "network.alpha.kubern
 class NetworkPluginConf {
 public:
     /* settings for net plugin */
-    NetworkPluginConf(const std::string &dockershimRootDirectory = "/var/lib/isulad/shim",
-                      const std::string &pluginConfDir = "/etc/cni/net.d/",
-                      const std::string &pluginBinDir = "/opt/cni/bin", const std::string &pluginName = "",
-                      const std::string &hairpinMode = "hairpin-veth", const std::string &nonMasqueradeCIDR = "",
-                      int32_t mtu = 1460)
+    explicit NetworkPluginConf(const std::string &dockershimRootDirectory = "/var/lib/isulad/shim",
+                               const std::string &pluginConfDir = "/etc/cni/net.d/",
+                               const std::string &pluginBinDir = "/opt/cni/bin", const std::string &pluginName = "",
+                               const std::string &hairpinMode = "hairpin-veth", const std::string &nonMasqueradeCIDR = "",
+                               int32_t mtu = 1460)
         : m_dockershimRootDirectory(dockershimRootDirectory),
           m_pluginConfDir(pluginConfDir),
           m_pluginBinDir(pluginBinDir),
-- 
2.40.1

