Skip to content

Commit 44b365f

Browse files
yjuglpchevrel@mozilla.com
authored andcommitted
Bug 1993904 - Acknowledge a possible failure during file copy/move. a=pascalc
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. Original Revision: https://phabricator.services.mozilla.com/D268845 Differential Revision: https://phabricator.services.mozilla.com/D269010
1 parent 0b440e8 commit 44b365f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

xpcom/io/nsLocalFileWin.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "mozilla/ArrayUtils.h"
88
#include "mozilla/Assertions.h"
99
#include "mozilla/DebugOnly.h"
10+
#include "mozilla/Maybe.h"
1011
#include "mozilla/ProfilerLabels.h"
1112
#include "mozilla/TextUtils.h"
1213
#include "mozilla/UniquePtrExtensions.h"
@@ -1867,9 +1868,11 @@ nsresult nsLocalFile::MoveOrCopyAsSingleFileOrDir(nsIFile* aDestParent,
18671868
return NS_ERROR_FILE_ACCESS_DENIED;
18681869
}
18691870

1870-
// Determine if we are a directory before any move/copy.
1871-
bool isDir = false;
1872-
MOZ_ALWAYS_SUCCEEDS(IsDirectory(&isDir));
1871+
// Attempt to determine if we are a directory before any move/copy.
1872+
auto isDir = Some(false);
1873+
if (NS_FAILED(IsDirectory(isDir.ptr()))) {
1874+
isDir.reset();
1875+
}
18731876

18741877
int copyOK = 0;
18751878
if (move) {
@@ -1936,7 +1939,8 @@ nsresult nsLocalFile::MoveOrCopyAsSingleFileOrDir(nsIFile* aDestParent,
19361939
// within the same volume. We check this to prevent unnecessary calls to
19371940
// SetNamedSecurityInfoW, this avoids a request for SeTcbPrivilege, which
19381941
// can cause a lot of audit events if enabled (Bug 1816694).
1939-
if (!ChildAclMatchesAclInheritedFromParent(WrapNotNull(childDacl), isDir,
1942+
if (isDir.isNothing() ||
1943+
!ChildAclMatchesAclInheritedFromParent(WrapNotNull(childDacl), *isDir,
19401944
childSecDesc, aDestParent)) {
19411945
// We don't expect this to fail, but it shouldn't crash in release.
19421946
MOZ_ALWAYS_TRUE(

0 commit comments

Comments
 (0)