Fix size_t range problem in weighted_target LB parsing code.

pull/22754/head
Mark D. Roth 5 years ago
parent baa442e6e4
commit 1cd6e86845
  1. 9
      src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc

@ -676,14 +676,15 @@ class WeightedTargetLbFactory : public LoadBalancingPolicyFactory {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:weight error:must be of type number"));
} else {
child_config->weight =
gpr_parse_nonnegative_int(it->second.string_value().c_str());
if (child_config->weight == -1) {
int weight = gpr_parse_nonnegative_int(it->second.string_value().c_str());
if (weight == -1) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:weight error:unparseable value"));
} else if (child_config->weight == 0) {
} else if (weight == 0) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:weight error:value must be greater than zero"));
} else {
child_config->weight = weight;
}
}
// Child policy.

Loading…
Cancel
Save