Skip to content

Commit 41b18d8

Browse files
authored
Merge pull request #2147 from GitoxideLabs/improvements
fix: consider a Windows resource untrusted if security information could not be retrieved (#2128)
2 parents 8d8dba2 + 0bd262d commit 41b18d8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gix-sec/src/identity.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mod impl_ {
8282

8383
pub fn is_path_owned_by_current_user(path: &Path) -> io::Result<bool> {
8484
use windows_sys::Win32::{
85-
Foundation::{GetLastError, LocalFree, ERROR_INSUFFICIENT_BUFFER, ERROR_SUCCESS},
85+
Foundation::{GetLastError, LocalFree, ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_FUNCTION, ERROR_SUCCESS},
8686
Security::{
8787
Authorization::{GetNamedSecurityInfoW, SE_FILE_OBJECT},
8888
CheckTokenMembership, EqualSid, GetTokenInformation, IsWellKnownSid, TokenOwner,
@@ -123,6 +123,11 @@ mod impl_ {
123123
);
124124

125125
if result != ERROR_SUCCESS {
126+
if result == ERROR_INVALID_FUNCTION {
127+
// We cannot obtain security information, so we default to reduced trust
128+
// (false) rather than failing completely.
129+
return Ok(false);
130+
}
126131
let inner = io::Error::from_raw_os_error(result as _);
127132
error!(
128133
inner,

0 commit comments

Comments
 (0)