diff options
| author | Hiiva <32042291+Hiiva@users.noreply.github.com> | 2026-11-23 16:07:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-23 08:07:54 -0600 |
| commit | d582abc17fa2d39e1d58277d14497d78a7f5adf9 (patch) | |
| tree | 37e38c699c5b566e5e796968237f224be6d02688 /runtime/shims/file_system.cpp | |
| parent | b9681ec4cea3124f0218048e30bec6345f3bc698 (diff) | |
runtime: reject deleting read-only package files (#5946)
Squash-merged after review of PR #5946 - BUILD-1899: Respect read-only attributes when deleting package files
Diffstat (limited to 'runtime/shims/file_system.cpp')
| -rw-r--r-- | runtime/shims/file_system.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/shims/file_system.cpp b/runtime/shims/file_system.cpp index 0ca9e04ac..bc148d12a 100644 --- a/runtime/shims/file_system.cpp +++ b/runtime/shims/file_system.cpp | |||
| @@ -890,6 +890,13 @@ BOOL WINAPI delete_file_w(LPCWSTR name) { | |||
| 890 | SetLastError(ERROR_ACCESS_DENIED); | 890 | SetLastError(ERROR_ACCESS_DENIED); |
| 891 | return FALSE; | 891 | return FALSE; |
| 892 | } | 892 | } |
| 893 | // The overlay delete already checked its own attributes. Without an overlay, the package file's | ||
| 894 | // read-only bit still applies even though deletion only writes a marker instead of deleting that file. | ||
| 895 | if (!removed) { | ||
| 896 | const DWORD attributes = ::GetFileAttributesW(package_path.c_str()); | ||
| 897 | if (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_READONLY) != 0) | ||
| 898 | return fail_bool(ERROR_ACCESS_DENIED); | ||
| 899 | } | ||
| 893 | // The package file stays where it is; the marker is what hides it. | 900 | // The package file stays where it is; the marker is what hides it. |
| 894 | DWORD error = 0; | 901 | DWORD error = 0; |
| 895 | if (!write_marker(marker(r.overlay, parts), error)) return fail_bool(error); | 902 | if (!write_marker(marker(r.overlay, parts), error)) return fail_bool(error); |