fix overflow in URL parsing #103
Open
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.
The fuzzer added in #102 finds an overflow in the URL parsing logic, with the following sanitizer report:
==13==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x5020001398f4 at pc 0x557be604430c bp 0x7ffe725a0400 sp 0x7ffe725a03f8 READ of size 1 at 0x5020001398f4 thread T0 SCARINESS: 12 (1-byte-read-heap-buffer-overflow) #0 0x557be604430b in http_parse_host /src/http-parser/./http_parser/http_parser.c:2015:58 #1 0x557be604430b in http_parser_parse_url /src/http-parser/./http_parser/http_parser.c:2150:9 #2 0x557be6039317 in LLVMFuzzerTestOneInput /src/fuzzer.c:19:3This fixes it by ensuring the
http_parse_hostfunction does not beyond the buffer it uses for reading.