Skip to content

only apply Range to a 206 response in write_content_with_provider - #2510

Open
metsw24-max wants to merge 1 commit into
yhirose:masterfrom
metsw24-max:range-206-only
Open

only apply Range to a 206 response in write_content_with_provider#2510
metsw24-max wants to merge 1 commit into
yhirose:masterfrom
metsw24-max:range-206-only

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

Unvalidated Range reaches the content provider on non-2xx responses

write_content_with_provider slices the representation whenever req.ranges is non-empty, but apply_ranges only slices for a 206 and detail::range_error only validates the ranges for a 2xx status, so a handler answering 403 through a content provider hands the client's raw offset straight down (ASAN: heap-buffer-overflow, READ of 201 bytes past a 7-byte buffer, which then goes out on the socket; the bounds asserts in get_range_offset_and_length are compiled out under NDEBUG). Gating on 206 to match apply_ranges also settles the 2xx-but-not-206 case, where the body written was shorter than the Content-Length already sent, and the added test covers both.

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