You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@brpc.apache.org by "phoenixlen (via GitHub)" <gi...@apache.org> on 2026/01/09 09:04:05 UTC
[I] 端口解析验证问题(Incorrect port number validation in address parsing) (brpc)
phoenixlen opened a new issue, #3192:
URL: https://github.com/apache/brpc/issues/3192
**Describe the bug**
file: butil/endpoint.cpp
function: int str2endpoint(const char* str, EndPoint* point) {
line: 291 for (++end; isspace(*end); ++end);
first "++end" is bug? should be for (; isspace(*end); ++end);
第一个"++end"是bug吧?应该是for (; isspace(*end); ++end);
char* end = NULL;
point->port = strtol(str + i, &end, 10);
if (end == str + i) {
return -1;
} else if (*end) {
for (++end; isspace(*end); ++end); // <-- BUG: increments end before checking
if (*end) {
return -1;
}
}
example: "0.0.0.0:8000a" is ok
例如"0.0.0.0:8000a" 中的a就被跳过了。
**To Reproduce**
**Expected behavior**
**Versions** 1.14.1
OS:
Compiler:
brpc:
protobuf:
**Additional context/screenshots**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For additional commands, e-mail: issues-help@brpc.apache.org
Re: [I] 端口解析验证问题(Incorrect port number validation in address parsing) (brpc)
Posted by "AnantShukla-Git-Hub (via GitHub)" <gi...@apache.org>.
AnantShukla-Git-Hub commented on issue #3192:
URL: https://github.com/apache/brpc/issues/3192#issuecomment-3728429664
Hi,
This PR fixes a bug in `butil/endpoint.cpp` within
`str2endpoint(const char* str, EndPoint* point)`.
Previously, the validation loop at line 291 incremented `end` before checking
for whitespace:
for (++end; isspace(*end); ++end);
This caused the first non-digit character after the port to be skipped,
allowing invalid inputs such as `0.0.0.0:8000a` to be accepted.
The fix removes the premature increment so that only whitespace is skipped:
for (; isspace(*end); ++end);
With this change, endpoint strings containing trailing non-whitespace
characters after the port are correctly rejected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For additional commands, e-mail: issues-help@brpc.apache.org
Re: [I] 端口解析验证问题(Incorrect port number validation in address parsing) (brpc)
Posted by "wasphin (via GitHub)" <gi...@apache.org>.
wasphin closed issue #3192: 端口解析验证问题(Incorrect port number validation in address parsing)
URL: https://github.com/apache/brpc/issues/3192
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@brpc.apache.org
For additional commands, e-mail: issues-help@brpc.apache.org