tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 22ca0db0b51b90ecdc85b8640964c2b752058358
parent 89f7e0c88faf97328ea3acc99b36faf0f55f7fe5
Author: Yannis Juglaret <yjuglaret@mozilla.com>
Date:   Thu, 16 Oct 2025 13:59:25 +0000

Bug 1993904 - Acknowledge a possible failure during file copy/move. r=win-reviewers,gstoll

We provide an alternate path if we can't determine whether the file we
are copying or moving is or isn't a directory. This information is only
required to potentially avoid a slow path, so in case we can't get it we
just continue with the copy/move operation and then unconditionally take
the slow path.

Differential Revision: https://phabricator.services.mozilla.com/D268845

Diffstat:
Mxpcom/io/nsLocalFileWin.cpp | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp @@ -7,6 +7,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Assertions.h" #include "mozilla/DebugOnly.h" +#include "mozilla/Maybe.h" #include "mozilla/ProfilerLabels.h" #include "mozilla/TextUtils.h" #include "mozilla/UniquePtrExtensions.h" @@ -1867,9 +1868,11 @@ nsresult nsLocalFile::MoveOrCopyAsSingleFileOrDir(nsIFile* aDestParent, return NS_ERROR_FILE_ACCESS_DENIED; } - // Determine if we are a directory before any move/copy. - bool isDir = false; - MOZ_ALWAYS_SUCCEEDS(IsDirectory(&isDir)); + // Attempt to determine if we are a directory before any move/copy. + auto isDir = Some(false); + if (NS_FAILED(IsDirectory(isDir.ptr()))) { + isDir.reset(); + } int copyOK = 0; if (move) { @@ -1936,7 +1939,8 @@ nsresult nsLocalFile::MoveOrCopyAsSingleFileOrDir(nsIFile* aDestParent, // within the same volume. We check this to prevent unnecessary calls to // SetNamedSecurityInfoW, this avoids a request for SeTcbPrivilege, which // can cause a lot of audit events if enabled (Bug 1816694). - if (!ChildAclMatchesAclInheritedFromParent(WrapNotNull(childDacl), isDir, + if (isDir.isNothing() || + !ChildAclMatchesAclInheritedFromParent(WrapNotNull(childDacl), *isDir, childSecDesc, aDestParent)) { // We don't expect this to fail, but it shouldn't crash in release. MOZ_ALWAYS_TRUE(