Merge pull request #21866 from markdroth/xds_bootstrap_error_fix

Fix bugs in xds bootstrap file parsing.
pull/21874/head
Mark D. Roth 5 years ago committed by GitHub
commit 2a7191abe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/core/ext/filters/client_channel/xds/xds_bootstrap.cc

@ -79,14 +79,15 @@ XdsBootstrap::XdsBootstrap(Json json, grpc_error** error) {
grpc_error* XdsBootstrap::ParseXdsServerList(Json* json) { grpc_error* XdsBootstrap::ParseXdsServerList(Json* json) {
InlinedVector<grpc_error*, 1> error_list; InlinedVector<grpc_error*, 1> error_list;
size_t idx = 0; for (size_t i = 0; i < json->mutable_array()->size(); ++i) {
for (Json& child : *json->mutable_array()) { Json& child = json->mutable_array()->at(i);
if (child.type() != Json::Type::OBJECT) { if (child.type() != Json::Type::OBJECT) {
char* msg; char* msg;
gpr_asprintf(&msg, "array element %" PRIuPTR " is not an object", idx); gpr_asprintf(&msg, "array element %" PRIuPTR " is not an object", i);
error_list.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg)); error_list.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg));
gpr_free(msg);
} else { } else {
grpc_error* parse_error = ParseXdsServer(&child, idx); grpc_error* parse_error = ParseXdsServer(&child, i);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error);
} }
} }
@ -140,6 +141,7 @@ grpc_error* XdsBootstrap::ParseChannelCredsArray(Json* json,
char* msg; char* msg;
gpr_asprintf(&msg, "array element %" PRIuPTR " is not an object", i); gpr_asprintf(&msg, "array element %" PRIuPTR " is not an object", i);
error_list.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg)); error_list.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg));
gpr_free(msg);
} else { } else {
grpc_error* parse_error = ParseChannelCreds(&child, i, server); grpc_error* parse_error = ParseChannelCreds(&child, i, server);
if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error); if (parse_error != GRPC_ERROR_NONE) error_list.push_back(parse_error);

Loading…
Cancel
Save