瀏覽代碼

Merge pull request #90069 from KoBeWi/file_suicide_prevention_measures

Don't allow copying file into its own path
Rémi Verschelde 1 年之前
父節點
當前提交
c53a4a7f64
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      core/io/dir_access.cpp

+ 2 - 0
core/io/dir_access.cpp

@@ -339,6 +339,8 @@ String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
 }
 }
 
 
 Error DirAccess::copy(const String &p_from, const String &p_to, int p_chmod_flags) {
 Error DirAccess::copy(const String &p_from, const String &p_to, int p_chmod_flags) {
+	ERR_FAIL_COND_V_MSG(p_from == p_to, ERR_INVALID_PARAMETER, "Source and destination path are equal.");
+
 	//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
 	//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
 	Error err;
 	Error err;
 	{
 	{