Repository navigation
Avoid out-of-bounds table read in balsa URI char validators #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -241,7 +241,7 @@ bool HasInvalidHeaderChars(absl::string_view value) { | |||||||||
| bool HasInvalidPathChar(absl::string_view value) { | ||||||||||
| static constexpr std::array<bool, 256> invalidCharTable = | ||||||||||
| buildInvalidPathCharLookupTable(); | ||||||||||
| for (const char c : value) { | ||||||||||
| for (const uint8_t c : value) { | ||||||||||
| if (invalidCharTable[c]) { | ||||||||||
| return true; | ||||||||||
| } | ||||||||||
|
|
@@ -252,7 +252,7 @@ bool HasInvalidPathChar(absl::string_view value) { | |||||||||
| bool HasInvalidQueryChar(absl::string_view value) { | ||||||||||
| static constexpr std::array<bool, 256> invalidCharTable = | ||||||||||
| buildInvalidQueryCharLookupTable(); | ||||||||||
| for (const char c : value) { | ||||||||||
| for (const uint8_t c : value) { | ||||||||||
| if (invalidCharTable[c]) { | ||||||||||
|
Comment on lines
+255
to
256
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implicitly converting
Suggested change
|
||||||||||
| return true; | ||||||||||
| } | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implicitly converting
chartouint8_tin the range-basedforloop can trigger compiler warnings (such as-Wsign-conversionor-Wconversion) in strict build environments. To prevent this and maintain consistency with other validators in this file (likeIsValidTokenandIsValidChunkExtension), it is better to iterate overconst char cand perform an explicitstatic_cast<uint8_t>(c)when indexing the lookup table.