Skip to content

mmap_file_iterator uses too restrictive sharing mode in a call to CreateFileA #778

@mikekaganski

Description

@mikekaganski

explicit mmap_file_iterator(std::string const& fileName)

CreateFileA call uses FILE_SHARE_READ as sharing mode. This makes this call fail, when the file is already open for writing, as explained at https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#parameters (see dwShareMode).

To allow opening files for reading, even when another process has it open for writing, but explicitly allowed reading using its own FILE_SHARE_READ, this call needs to use FILE_SHARE_READ | FILE_SHARE_WRITE (and maybe even also | FILE_SHARE_DELETE).

https://bugs.documentfoundation.org/show_bug.cgi?id=158442 was caused by this problem (fixed by patching spirit).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions