diff --git a/interfaces/kits/js/src/mod_fs/properties/copy_dir_core.cpp b/interfaces/kits/js/src/mod_fs/properties/copy_dir_core.cpp index b824647e3bbdac890da2eb9d6bfa87d096ee50a0..059fc0e6fb85874716c0f6cb7dc802be803581c5 100644 --- a/interfaces/kits/js/src/mod_fs/properties/copy_dir_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/copy_dir_core.cpp @@ -44,6 +44,7 @@ static bool AllowToCopy(const string &src, const string &dest) HILOGE("Failed to copy file, the same path"); return false; } + if (EndWithSlash(src) ? dest.find(src) == 0 : dest.find(src + "/") == 0) { HILOGE("Failed to copy file, dest is under src"); return false;