Repository navigation
Pass unsigned char to the ctype calls in ExtensionsParser and ParameterParser - #1971
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Two header parsers pass a plain
charto<cctype>, so any byte from 0x80 to 0xFF becomes a negative int that is not EOF, which is undefined behaviour (C11 7.4p1). HttpParser accepts those bytes in field values, so both are reachable from a client:ExtensionsParser::getToken(isalnum,isdigit) runs onSec-WebSocket-Extensionsduring the upgrade, before any application codeParameterParser::getToken(isspace) runs on the Content-Disposition line of a multipart part, where an unquoted UTF-8filename=é.txtis enoughWith the Windows UCRT (the clang++ setup of the build_windows job), a debug build asserts
c >= -1 && c <= 255in isctype.cpp forSec-WebSocket-Extensions: permessage-deflate; <0xE9>client_max_window_bitsand for the filename above. With the cast both parse the same as before and the assertion is gone. These are all the ctype calls in src/. glibc tolerates negative values, which is why the fuzzers don't see it, so there is no new test; tests/ExtensionsNegotiator, Query, HttpParser, ChunkedEncoding and BloomFilter still pass under ASan.