From 78bde303bfcfc9393420ce6de5db313ade703432 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 22 May 2020 15:50:43 +0900 Subject: Add path checking at multi pkg install APIs Change-Id: I3a07d3f9c1b52b8c4ee871d043a7c797abc52d7c Signed-off-by: Sangyoon Jang --- client/src/pkgmgr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index e30b3f9..cfbeb09 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -400,6 +400,13 @@ API int pkgmgr_client_usr_install_packages(pkgmgr_client *pc, return PKGMGR_R_EINVAL; } + for (i = 0; i < n_pkgs; i++) { + if (access(pkg_paths[i], F_OK) != 0) { + ERR("failed to access: %s", pkg_paths[i]); + return PKGMGR_R_EINVAL; + } + } + pkgs_builder = g_variant_builder_new(G_VARIANT_TYPE("as")); for (i = 0; i < n_pkgs; i++) g_variant_builder_add(pkgs_builder, "s", pkg_paths[i]); @@ -635,6 +642,13 @@ API int pkgmgr_client_usr_mount_install_packages(pkgmgr_client *pc, return PKGMGR_R_EINVAL; } + for (i = 0; i < n_pkgs; i++) { + if (access(pkg_paths[i], F_OK) != 0) { + ERR("failed to access: %s", pkg_paths[i]); + return PKGMGR_R_EINVAL; + } + } + pkgs_builder = g_variant_builder_new(G_VARIANT_TYPE("as")); for (i = 0; i < n_pkgs; i++) g_variant_builder_add(pkgs_builder, "s", pkg_paths[i]); -- cgit v1.2.3