Skip to content

fail mmap::open when ::mmap returns MAP_FAILED - #2511

Open
metsw24-max wants to merge 1 commit into
yhirose:masterfrom
metsw24-max:mmap-map-failed-guard
Open

fail mmap::open when ::mmap returns MAP_FAILED#2511
metsw24-max wants to merge 1 commit into
yhirose:masterfrom
metsw24-max:mmap-map-failed-guard

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

the posix branch of detail::mmap::open only tests MAP_FAILED as part of the empty-file case, so a failed mapping of a non-empty file leaves the sentinel in addr_ and open() still returns true. is_open() compares addr_ against nullptr alone, so callers pass the guard and data() hands back (const char *)-1, which handle_file_request and the set_file_content path in process_request both feed to a content provider as data() + offset, with offset coming from the client's Range header and the length bounded by the fstat size rather than by any mapping. the windows branch already closes and fails on every mapping error, so this mostly brings posix into line with it. mapping a directory is the easiest way to reach the failure, since ::open and fstat succeed there and ::mmap does not, and that is what the added test uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant