Skip to content

端口解析验证问题(Incorrect port number validation in address parsing) #3192

Description

@phoenixlen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions