Repository navigation
NamedFile: no panic on pre-epoch modification times or on an empty or degenerate Range - #37
Open
AlexeyMatskevich wants to merge 1 commit into
Open
AlexeyMatskevich wants to merge 1 commit into
AlexeyMatskevich wants to merge 1 commit into
Conversation
An empty Range header, or an mtime before 1970 or from year 10000 on, panicked; bytes=-0 got 206. Now an empty Range and bytes=-0 get 416, and files with such mtimes are served without the affected validator.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With ntex-files, one request can panic the handler: an empty
Rangeheader, or a request for a file whose modification time is before 1970 or in year 10000 or later. A suffix range on an empty file overflows an integer subtraction, andRange: bytes=-0on a non-empty file gets206, although a zero-length range cannot be satisfied (RFC 9110 section 14.1.2).What changes
200, withoutETagand withoutLast-Modified(test: test_modified_before_epoch).use_etag(false), such a file is served with200and withoutLast-Modified(test: test_modified_before_epoch_without_etag).200and anETag, withoutLast-Modified(test: test_modified_after_year_9999).Rangeheader with no range in it ("",bytes=,bytes=,,bytes= , ,) gets416withContent-Range: bytes */<len>(test: test_named_file_empty_range_header).bytes=-0gets416withContent-Range: bytes */<len>, also on an empty file (tests: test_named_file_zero_length_suffix_range, test_named_file_range_responses_match_the_selected_bytes).HttpRange::parseskips a zero-length suffix range:bytes=-0yields no range,bytes=-0,2-3yields2-3(test: test_parse).bytes=-5on an empty file gets200with an empty body and noContent-Range(test: test_named_file_suffix_range_of_empty_file).Reference
actix-files fixed the same for pre-1970 files in actix/actix-web#3922.
This PR and "NamedFile: support If-Range" touch the same lines of
ntex-files/src/lib.rs; the one merged second needs a rebase.