Fix port parsing validation in str2endpoint#3193
Merged
wasphin merged 2 commits intoapache:masterfrom Jan 12, 2026
Merged
Conversation
Signed-off-by: Anant Shukla <anantshukla836@gmail.com>
chenBright
reviewed
Jan 10, 2026
Contributor
chenBright
left a comment
There was a problem hiding this comment.
Please add a unit test in endpoint_unittest.cpp.
Signed-off-by: Anant Shukla <anantshukla836@gmail.com>
Contributor
Author
|
👍Added unit tests in endpoint_unittest.cpp. |
zchuango
pushed a commit
to zchuango/brpc
that referenced
this pull request
May 9, 2026
* Fix port parsing validation in str2endpoint Signed-off-by: Anant Shukla <anantshukla836@gmail.com> * Add unit tests for rejecting trailing characters after port parsing Signed-off-by: Anant Shukla <anantshukla836@gmail.com> --------- Signed-off-by: Anant Shukla <anantshukla836@gmail.com>
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.
Issue Number: resolves #3192
Problem Summary:
str2endpoint(const char* str, EndPoint* point)incorrectly accepts invalidendpoint strings where the port number is followed by non-whitespace
characters (e.g. "127.0.0.1:8000a").
This happens because the current validation logic skips the first non-digit
character before checking for whitespace, causing invalid ports to be treated
as valid.
What is changed and the side effects?
Changed:
str2endpointby ensuring that onlywhitespace characters are skipped after port parsing.
correctly rejected.