Skip to content

Conversation

@nilsding
Copy link
Member

GetFileSecurityW/SetFileSecurityW can not deal with long paths, even with the special \\?\ prefix.

Since CreateFileW can deal with those paths just fine, refactor the handling of DACLs to make use of a file handle returned by it with GetSecurityInfo/SetSecurityInfo.

This change also resolves an issue seen in #8860 where the access denied ACE would be present more than once.

@nilsding
Copy link
Member Author

/backport to stable-4.0

`GetFileSecurityW`/`SetFileSecurityW` can not deal with long paths, even
with the special `\\?\` prefix.

Since `CreateFileW` can deal with those paths just fine, refactor the
handling of DACLs to make use of `GetSecurityInfo`/`SetSecurityInfo`.

This change also resolves an issue seen in #8860 where the access denied
ACE would be present more than once.

Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
…Win32 buffers

Apparently std::unique_ptr can be made to work with `HANDLE`s and
whatever buffers allocated from the Win32 API need to be freed.  This
allows for much cleaner and safer code.

Some related articles on that topic from "The Old New Thing" blog:
- "Confusing gotcha: PSECURITY_DESCRIPTOR is not a pointer to a
  SECURITY_DESCRIPTOR" (23rd of December 2015)
  https://devblogs.microsoft.com/oldnewthing/20151223-00/?p=92701
- "Why are HANDLE return values so inconsistent?" (2nd of March 2004)
  https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443

Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
@nilsding nilsding force-pushed the bugfix/noid/max-path-readonly-check branch from 5ce80af to 4efedfb Compare November 21, 2025 10:45
@github-actions
Copy link

Artifact containing the AppImage: nextcloud-appimage-pr-9109.zip

Digest: sha256:4d5a209cfdb6212cfe17b72363b50d83c66a3390abd4ecc426bc253b341fdc86

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
93 New Code Smells (required ≤ 0)
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@mgallien mgallien merged commit 7ce3b84 into master Nov 21, 2025
21 of 22 checks passed
@mgallien mgallien deleted the bugfix/noid/max-path-readonly-check branch November 21, 2025 15:26
@mgallien mgallien modified the milestones: 4.0.2, 4.1.0 Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants