76 lines
2.3 KiB
Diff
76 lines
2.3 KiB
Diff
From e9f32090179a188464466d84904bc361cbb94ebc Mon Sep 17 00:00:00 2001
|
|
From: zhongtao <zhongtao17@huawei.com>
|
|
Date: Fri, 14 Jun 2024 09:55:28 +0800
|
|
Subject: [PATCH 218/226] bugfix for file param verify
|
|
|
|
Signed-off-by: zhongtao <zhongtao17@huawei.com>
|
|
---
|
|
src/cmd/isula/base/create.c | 19 +++++++++++++++++++
|
|
src/cmd/isula/images/load.c | 6 ++++++
|
|
2 files changed, 25 insertions(+)
|
|
|
|
diff --git a/src/cmd/isula/base/create.c b/src/cmd/isula/base/create.c
|
|
index 5756e6ad..865be4ed 100644
|
|
--- a/src/cmd/isula/base/create.c
|
|
+++ b/src/cmd/isula/base/create.c
|
|
@@ -290,6 +290,12 @@ static int append_env_variables_to_conf(const char *env_file, isula_container_co
|
|
int ret = 0;
|
|
size_t file_size;
|
|
|
|
+ if (util_dir_exists(env_file)) {
|
|
+ COMMAND_ERROR("Env file is a directory: %s", env_file);
|
|
+ ret = -1;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
if (!util_file_exists(env_file)) {
|
|
COMMAND_ERROR("env file not exists: %s", env_file);
|
|
ret = -1;
|
|
@@ -425,6 +431,12 @@ static int append_labels_to_conf(const char *label_file, isula_container_config_
|
|
int ret = 0;
|
|
size_t file_size;
|
|
|
|
+ if (util_dir_exists(label_file)) {
|
|
+ COMMAND_ERROR("Label file is a directory: %s", label_file);
|
|
+ ret = -1;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
if (!util_file_exists(label_file)) {
|
|
COMMAND_ERROR("label file not exists: %s", label_file);
|
|
ret = -1;
|
|
@@ -2135,6 +2147,13 @@ static int create_check_env_target_file(const struct client_arguments *args)
|
|
ret = -1;
|
|
goto out;
|
|
}
|
|
+
|
|
+ if (util_dir_exists(env_path)) {
|
|
+ COMMAND_ERROR("Env target file is a directory: %s", env_path);
|
|
+ ret = -1;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
if (!util_file_exists(env_path)) {
|
|
goto out;
|
|
}
|
|
diff --git a/src/cmd/isula/images/load.c b/src/cmd/isula/images/load.c
|
|
index 48422438..46e04310 100644
|
|
--- a/src/cmd/isula/images/load.c
|
|
+++ b/src/cmd/isula/images/load.c
|
|
@@ -162,6 +162,12 @@ int cmd_load_main(int argc, const char **argv)
|
|
g_cmd_load_args.file = file;
|
|
}
|
|
|
|
+ if (util_dir_exists(g_cmd_load_args.file)) {
|
|
+ COMMAND_ERROR("Load file is a directory: %s", g_cmd_load_args.file);
|
|
+ ret = -1;
|
|
+ exit(exit_code);
|
|
+ }
|
|
+
|
|
if (!util_file_exists(g_cmd_load_args.file)) {
|
|
COMMAND_ERROR("File %s is not exist", g_cmd_load_args.file);
|
|
exit(exit_code);
|
|
--
|
|
2.33.0
|
|
|