From e271b4e4945ed6f9cfdf3f3a8b3c328e10c514fd Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 27 Jul 2023 12:23:39 -0400 Subject: [PATCH] copyToUnique: Fail if source contains destination To prevent unbounded recursion as in 16547f64c244b7d75758735f97a62168d5f94475. --- chrome/content/zotero/xpcom/file.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 7cc97bcd62..6bf705989f 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -999,6 +999,10 @@ Zotero.File = new function(){ file = this.pathToFile(file); newFile = this.pathToFile(newFile); + if (file.contains(newFile)) { + throw new Error("Can't copy file into itself"); + } + newFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o644); var newName = newFile.leafName; newFile.remove(null);