upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/file_system.cpp
diff options
context:
space:
mode:
authorkotorvr <332716892+kotorvr@users.noreply.github.com>2026-11-22 20:48:04 +0000
committerkotorvr <332716892+kotorvr@users.noreply.github.com>2026-11-22 20:48:04 +0000
commit0977b5dc7ed6638a6e13aa94df11149b5b601f7b (patch)
treee140ecf5c3fc5bdf2fd76b4bc61ce691e273c492 /runtime/shims/file_system.cpp
parentf847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff)
file_system: a MAXIMUM_ALLOWED open is a write-open, so it cannot write the package
writes() did not count MAXIMUM_ALLOWED as write access. CreateFileW/A and CreateFile2 then opened the package file itself, and a WriteFile through the handle changed the package, which docs/runtime_imports.md says is never written. Such an open now gets the overlay copy like any other write-open. file_system_test: the three entry points, with the package bytes and the overlay copy checked after a write; a plain read still makes no overlay copy. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/file_system.cpp')
-rw-r--r--runtime/shims/file_system.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/shims/file_system.cpp b/runtime/shims/file_system.cpp
index 2e7d93718..7c308fe70 100644
--- a/runtime/shims/file_system.cpp
+++ b/runtime/shims/file_system.cpp
@@ -325,9 +325,11 @@ Target write_target(const std::wstring& path, bool copy_up) {
325 return t; 325 return t;
326} 326}
327 327
328// MAXIMUM_ALLOWED names no right and grants every one the file allows, write included, so it is a write-open: opened
329// as a read it handed out a handle to the package file itself, and a WriteFile through it changed the package.
328bool writes(DWORD access, DWORD disposition) { 330bool writes(DWORD access, DWORD disposition) {
329 constexpr DWORD kWriteAccess = GENERIC_WRITE | GENERIC_ALL | FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_WRITE_EA | 331 constexpr DWORD kWriteAccess = GENERIC_WRITE | GENERIC_ALL | MAXIMUM_ALLOWED | FILE_WRITE_DATA | FILE_APPEND_DATA |
330 FILE_WRITE_ATTRIBUTES | DELETE | WRITE_DAC | WRITE_OWNER; 332 FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES | DELETE | WRITE_DAC | WRITE_OWNER;
331 if ((access & kWriteAccess) != 0) return true; 333 if ((access & kWriteAccess) != 0) return true;
332 return disposition == CREATE_NEW || disposition == CREATE_ALWAYS || disposition == OPEN_ALWAYS || 334 return disposition == CREATE_NEW || disposition == CREATE_ALWAYS || disposition == OPEN_ALWAYS ||
333 disposition == TRUNCATE_EXISTING; 335 disposition == TRUNCATE_EXISTING;