sal/osl/w32/file_dirvol.cxx |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 1a4f72f03b1bd49d486e52135e78971242fae649
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Oct 11 18:49:56 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat Oct 11 17:27:04 2025 +0200

    tdf#150118: fix call to AccessCheck
    
    It turns out, that despite PrivilegeSet argument is documented as
    optional, the function fails without it. So my advise to avoid it
    was incorrect after all.
    
    Also, SAL_WARN takes area as the first argument, and a stream as
    the second. It makes no sense to "recode" GetLastError result: it
    is most informative as is.
    
    Change-Id: Ifd4d4ddc96f5e001c898f7331148b47aeee77f2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192227
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
index d2a87fbaac21..748a431dd4f9 100644
--- a/sal/osl/w32/file_dirvol.cxx
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -1549,10 +1549,12 @@ oslFileError SAL_CALL osl_getFileStatus(
                 = { FILE_GENERIC_READ, FILE_GENERIC_WRITE, 
FILE_GENERIC_EXECUTE, FILE_ALL_ACCESS };
             DWORD grantedAccess = 0;
             BOOL accessStatus = TRUE;
+            PRIVILEGE_SET privSet;
+            DWORD privSetSize = sizeof(privSet);
 
             // 
https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-accesscheck
             BOOL bResult = AccessCheck(pSD, hImpersonationToken, 
FILE_GENERIC_WRITE, &mapping,
-                                       nullptr, nullptr, &grantedAccess, 
&accessStatus);
+                                       &privSet, &privSetSize, &grantedAccess, 
&accessStatus);
 
             if (bResult)
             {
@@ -1564,13 +1566,13 @@ oslFileError SAL_CALL osl_getFileStatus(
             }
             else
             {
-                SAL_WARN("AccessCheck API failed with: ", 
oslTranslateFileError(GetLastError()));
+                SAL_WARN("sal.osl", "AccessCheck API failed with: " << 
GetLastError());
             }
             LocalFree(pSD); // free memory
         }
         else
         {
-            SAL_WARN("GetNamedSecurityInfoW API failed with: ", aResult);
+            SAL_WARN("sal.osl", "GetNamedSecurityInfoW API failed with: " << 
aResult);
         }
         CloseHandle(hImpersonationToken); // free memory
         CloseHandle(hProcessToken); // free memory

Reply via email to