songgaoye commented on code in PR #3669:
URL: https://github.com/apache/brpc/pull/3669#discussion_r4387773720
##########
src/brpc/policy/http_rpc_protocol.cpp:
##########
@@ -420,8 +421,15 @@ void ProcessHttpResponse(InputMessageBase* msg) {
}
const std::string* grpc_status =
res_header->GetHeader(common->GRPC_STATUS);
if (grpc_status) {
- // TODO: More strict parsing
- GrpcStatus status = (GrpcStatus)strtol(grpc_status->data(),
nullptr, 10);
+ int code = 0;
+ if (!butil::StringToInt(*grpc_status, &code)) {
+ cntl->SetFailed(ERESPONSE, "Invalid grpc-status header");
+ break;
+ }
+ const GrpcStatus status =
+ code >= GRPC_OK && code < GRPC_MAX
+ ? static_cast<GrpcStatus>(code)
+ : GRPC_UNKNOWN;
Review Comment:
update pr description.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]