cast to unsigned char before tolower/toupper/isdigit calls - #1650
Open
Mounika2456 wants to merge 1 commit into
Open
cast to unsigned char before tolower/toupper/isdigit calls#1650Mounika2456 wants to merge 1 commit into
Mounika2456 wants to merge 1 commit into
Conversation
✅ Deploy Preview for dpp-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
have you tested this in real world conditions, not in a fabricated shim? |
Contributor
|
Depending on the libc that indexes outside the ctype table, and the MSVC debug CRT asserts on it. depending how? this feels like an assumption. |
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.
dpp::lowercase/dpp::uppercasehand the Ctolower/toupperstraight tostd::transformover astd::string, so every element is acharwidened toint:tolower/toupperare only defined for arguments representable asunsigned charorEOF. Wherecharis signed, any byte >= 0x80 arrives as a negative value, which is out of that contract. These helpers normalize untrusted input: prefix command names incommandhandler/slashcommand, and the request line plus header keys parsed by the interactionshttp_server. A UTF-8 name likecaféor a header key with a high byte is enough to reach the call with a negative argument. Depending on the libc that indexes outside the ctype table, and the MSVC debug CRT asserts on it.Two
isdigit(*str.c_str())calls incluster/confirmation.cpp(error field-name handling) have the same problem.The cast to
unsigned charat each call site matches the fix already applied to thetolowerlambdas inhttpsclient.cpp. Valid input is unaffected; bytes >= 0x80 still pass through unchanged. Built againstdevand the offline unit tests pass.Code change checklist