More pointer conversions, deprecated string to char *, goto crossing initializations

reviewable/pr12692/r4
Yash Tibrewal 7 years ago
parent 20987394e9
commit acd46e571c
  1. 8
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
  2. 10
      src/core/ext/transport/cronet/transport/cronet_transport.c
  3. 3
      src/core/lib/http/httpcli_security_connector.c
  4. 20
      src/core/lib/security/context/security_context.c
  5. 12
      src/core/lib/security/credentials/composite/composite_credentials.c
  6. 22
      src/core/lib/security/credentials/credentials.c
  7. 3
      src/core/lib/security/credentials/credentials_metadata.c
  8. 13
      src/core/lib/security/credentials/fake/fake_credentials.c
  9. 6
      src/core/lib/security/credentials/google_default/google_default_credentials.c
  10. 3
      src/core/lib/security/credentials/iam/iam_credentials.c
  11. 2
      src/core/lib/security/credentials/jwt/json_token.c
  12. 3
      src/core/lib/security/credentials/jwt/jwt_credentials.c
  13. 23
      src/core/lib/security/credentials/jwt/jwt_verifier.c
  14. 23
      src/core/lib/security/credentials/oauth2/oauth2_credentials.c
  15. 3
      src/core/lib/security/credentials/plugin/plugin_credentials.c
  16. 13
      src/core/lib/security/credentials/ssl/ssl_credentials.c
  17. 31
      src/core/lib/security/transport/client_auth_filter.c
  18. 13
      src/core/lib/security/transport/lb_targets_info.c
  19. 35
      src/core/lib/security/transport/security_connector.c
  20. 30
      src/core/lib/security/transport/server_auth_filter.c
  21. 26
      src/core/tsi/fake_transport_security.c
  22. 28
      src/core/tsi/ssl_transport_security.c
  23. 3
      src/core/tsi/transport_security.c
  24. 10
      src/core/tsi/transport_security_adapter.c

@ -86,7 +86,8 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args(
if (target_uri->path[0] != '\0') { // "path" may be empty if (target_uri->path[0] != '\0') { // "path" may be empty
const grpc_slice key = grpc_slice_from_static_string( const grpc_slice key = grpc_slice_from_static_string(
target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path); target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path);
const char *value = grpc_slice_hash_table_get(targets_info, key); const char *value =
(const char *)grpc_slice_hash_table_get(targets_info, key);
if (value != NULL) target_name_to_check = gpr_strdup(value); if (value != NULL) target_name_to_check = gpr_strdup(value);
grpc_slice_unref_internal(exec_ctx, key); grpc_slice_unref_internal(exec_ctx, key);
} }
@ -127,7 +128,8 @@ static grpc_subchannel_args *get_secure_naming_subchannel_args(
if (new_args_from_connector != NULL) { if (new_args_from_connector != NULL) {
grpc_channel_args_destroy(exec_ctx, new_args_from_connector); grpc_channel_args_destroy(exec_ctx, new_args_from_connector);
} }
grpc_subchannel_args *final_sc_args = (grpc_subchannel_args*) gpr_malloc(sizeof(*final_sc_args)); grpc_subchannel_args *final_sc_args =
(grpc_subchannel_args *)gpr_malloc(sizeof(*final_sc_args));
memcpy(final_sc_args, args, sizeof(*args)); memcpy(final_sc_args, args, sizeof(*args));
final_sc_args->args = new_args; final_sc_args->args = new_args;
return final_sc_args; return final_sc_args;
@ -164,7 +166,7 @@ static grpc_channel *client_channel_factory_create_channel(
} }
// Add channel arg containing the server URI. // Add channel arg containing the server URI.
grpc_arg arg = grpc_channel_arg_string_create( grpc_arg arg = grpc_channel_arg_string_create(
GRPC_ARG_SERVER_URI, (char *)GRPC_ARG_SERVER_URI,
grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target)); grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target));
const char *to_remove[] = {GRPC_ARG_SERVER_URI}; const char *to_remove[] = {GRPC_ARG_SERVER_URI};
grpc_channel_args *new_args = grpc_channel_args *new_args =

@ -313,7 +313,8 @@ static void add_to_storage(struct stream_obj *s,
struct op_storage *storage = &s->storage; struct op_storage *storage = &s->storage;
/* add new op at the beginning of the linked list. The memory is freed /* add new op at the beginning of the linked list. The memory is freed
in remove_from_storage */ in remove_from_storage */
struct op_and_state *new_op = (struct op_and_state*) gpr_malloc(sizeof(struct op_and_state)); struct op_and_state *new_op =
(struct op_and_state *)gpr_malloc(sizeof(struct op_and_state));
memcpy(&new_op->op, op, sizeof(grpc_transport_stream_op_batch)); memcpy(&new_op->op, op, sizeof(grpc_transport_stream_op_batch));
memset(&new_op->state, 0, sizeof(new_op->state)); memset(&new_op->state, 0, sizeof(new_op->state));
new_op->s = s; new_op->s = s;
@ -1182,7 +1183,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
stream_state->rs.length_field); stream_state->rs.length_field);
if (stream_state->rs.length_field > 0) { if (stream_state->rs.length_field > 0) {
stream_state->rs.read_buffer = stream_state->rs.read_buffer =
gpr_malloc((size_t)stream_state->rs.length_field); (char *)gpr_malloc((size_t)stream_state->rs.length_field);
GPR_ASSERT(stream_state->rs.read_buffer); GPR_ASSERT(stream_state->rs.read_buffer);
stream_state->rs.remaining_bytes = stream_state->rs.length_field; stream_state->rs.remaining_bytes = stream_state->rs.length_field;
stream_state->rs.received_bytes = 0; stream_state->rs.received_bytes = 0;
@ -1452,12 +1453,13 @@ static const grpc_transport_vtable grpc_cronet_vtable = {
grpc_transport *grpc_create_cronet_transport(void *engine, const char *target, grpc_transport *grpc_create_cronet_transport(void *engine, const char *target,
const grpc_channel_args *args, const grpc_channel_args *args,
void *reserved) { void *reserved) {
grpc_cronet_transport *ct = (grpc_cronet_transport*) gpr_malloc(sizeof(grpc_cronet_transport)); grpc_cronet_transport *ct =
(grpc_cronet_transport *)gpr_malloc(sizeof(grpc_cronet_transport));
if (!ct) { if (!ct) {
goto error; goto error;
} }
ct->base.vtable = &grpc_cronet_vtable; ct->base.vtable = &grpc_cronet_vtable;
ct->engine = engine; ct->engine = (stream_engine *)engine;
ct->host = (char *)gpr_malloc(strlen(target) + 1); ct->host = (char *)gpr_malloc(strlen(target) + 1);
if (!ct->host) { if (!ct->host) {
goto error; goto error;

@ -106,7 +106,8 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
} }
c = (grpc_httpcli_ssl_channel_security_connector*) gpr_zalloc(sizeof(grpc_httpcli_ssl_channel_security_connector)); c = (grpc_httpcli_ssl_channel_security_connector *)gpr_zalloc(
sizeof(grpc_httpcli_ssl_channel_security_connector));
gpr_ref_init(&c->base.base.refcount, 1); gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.vtable = &httpcli_ssl_vtable; c->base.base.vtable = &httpcli_ssl_vtable;

@ -82,7 +82,8 @@ void grpc_auth_context_release(grpc_auth_context *context) {
/* --- grpc_client_security_context --- */ /* --- grpc_client_security_context --- */
grpc_client_security_context *grpc_client_security_context_create(void) { grpc_client_security_context *grpc_client_security_context_create(void) {
return (grpc_client_security_context*)gpr_zalloc(sizeof(grpc_client_security_context)); return (grpc_client_security_context *)gpr_zalloc(
sizeof(grpc_client_security_context));
} }
void grpc_client_security_context_destroy(void *ctx) { void grpc_client_security_context_destroy(void *ctx) {
@ -100,7 +101,8 @@ void grpc_client_security_context_destroy(void *ctx) {
/* --- grpc_server_security_context --- */ /* --- grpc_server_security_context --- */
grpc_server_security_context *grpc_server_security_context_create(void) { grpc_server_security_context *grpc_server_security_context_create(void) {
return (grpc_client_security_context*)gpr_zalloc(sizeof(grpc_server_security_context)); return (grpc_server_security_context *)gpr_zalloc(
sizeof(grpc_server_security_context));
} }
void grpc_server_security_context_destroy(void *ctx) { void grpc_server_security_context_destroy(void *ctx) {
@ -117,7 +119,8 @@ void grpc_server_security_context_destroy(void *ctx) {
static grpc_auth_property_iterator empty_iterator = {NULL, 0, NULL}; static grpc_auth_property_iterator empty_iterator = {NULL, 0, NULL};
grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained) { grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained) {
grpc_auth_context *ctx = (grpc_auth_context*) gpr_zalloc(sizeof(grpc_auth_context)); grpc_auth_context *ctx =
(grpc_auth_context *)gpr_zalloc(sizeof(grpc_auth_context));
gpr_ref_init(&ctx->refcount, 1); gpr_ref_init(&ctx->refcount, 1);
if (chained != NULL) { if (chained != NULL) {
ctx->chained = GRPC_AUTH_CONTEXT_REF(chained, "chained"); ctx->chained = GRPC_AUTH_CONTEXT_REF(chained, "chained");
@ -258,8 +261,8 @@ static void ensure_auth_context_capacity(grpc_auth_context *ctx) {
if (ctx->properties.count == ctx->properties.capacity) { if (ctx->properties.count == ctx->properties.capacity) {
ctx->properties.capacity = ctx->properties.capacity =
GPR_MAX(ctx->properties.capacity + 8, ctx->properties.capacity * 2); GPR_MAX(ctx->properties.capacity + 8, ctx->properties.capacity * 2);
ctx->properties.array = (grpc_auth_property *) ctx->properties.array = (grpc_auth_property *)gpr_realloc(
gpr_realloc(ctx->properties.array, ctx->properties.array,
ctx->properties.capacity * sizeof(grpc_auth_property)); ctx->properties.capacity * sizeof(grpc_auth_property));
} }
} }
@ -306,7 +309,8 @@ static void auth_context_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
} }
static void *auth_context_pointer_arg_copy(void *p) { static void *auth_context_pointer_arg_copy(void *p) {
return GRPC_AUTH_CONTEXT_REF((grpc_auth_context*)p, "auth_context_pointer_arg"); return GRPC_AUTH_CONTEXT_REF((grpc_auth_context *)p,
"auth_context_pointer_arg");
} }
static int auth_context_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); } static int auth_context_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
@ -316,8 +320,8 @@ static const grpc_arg_pointer_vtable auth_context_pointer_vtable = {
auth_context_pointer_cmp}; auth_context_pointer_cmp};
grpc_arg grpc_auth_context_to_arg(grpc_auth_context *p) { grpc_arg grpc_auth_context_to_arg(grpc_auth_context *p) {
return grpc_channel_arg_pointer_create(GRPC_AUTH_CONTEXT_ARG, p, return grpc_channel_arg_pointer_create((char *)GRPC_AUTH_CONTEXT_ARG, p,
(char *)&auth_context_pointer_vtable); &auth_context_pointer_vtable);
} }
grpc_auth_context *grpc_auth_context_from_arg(const grpc_arg *arg) { grpc_auth_context *grpc_auth_context_from_arg(const grpc_arg *arg) {

@ -79,7 +79,8 @@ static bool composite_call_get_request_metadata(
grpc_error **error) { grpc_error **error) {
grpc_composite_call_credentials *c = (grpc_composite_call_credentials *)creds; grpc_composite_call_credentials *c = (grpc_composite_call_credentials *)creds;
grpc_composite_call_credentials_metadata_context *ctx; grpc_composite_call_credentials_metadata_context *ctx;
ctx = (grpc_composite_call_credentials_metadata_context*) gpr_zalloc(sizeof(grpc_composite_call_credentials_metadata_context)); ctx = (grpc_composite_call_credentials_metadata_context *)gpr_zalloc(
sizeof(grpc_composite_call_credentials_metadata_context));
ctx->composite_creds = c; ctx->composite_creds = c;
ctx->pollent = pollent; ctx->pollent = pollent;
ctx->auth_md_context = auth_md_context; ctx->auth_md_context = auth_md_context;
@ -146,7 +147,8 @@ grpc_call_credentials *grpc_composite_call_credentials_create(
GPR_ASSERT(reserved == NULL); GPR_ASSERT(reserved == NULL);
GPR_ASSERT(creds1 != NULL); GPR_ASSERT(creds1 != NULL);
GPR_ASSERT(creds2 != NULL); GPR_ASSERT(creds2 != NULL);
c = (grpc_composite_call_credentials*) gpr_zalloc(sizeof(grpc_composite_call_credentials)); c = (grpc_composite_call_credentials *)gpr_zalloc(
sizeof(grpc_composite_call_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE; c->base.type = GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE;
c->base.vtable = &composite_call_credentials_vtable; c->base.vtable = &composite_call_credentials_vtable;
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.refcount, 1);
@ -154,7 +156,8 @@ grpc_call_credentials *grpc_composite_call_credentials_create(
creds2_array = get_creds_array(&creds2); creds2_array = get_creds_array(&creds2);
c->inner.num_creds = creds1_array.num_creds + creds2_array.num_creds; c->inner.num_creds = creds1_array.num_creds + creds2_array.num_creds;
creds_array_byte_size = c->inner.num_creds * sizeof(grpc_call_credentials *); creds_array_byte_size = c->inner.num_creds * sizeof(grpc_call_credentials *);
c->inner.creds_array = (grpc_call_credentials**) gpr_zalloc(creds_array_byte_size); c->inner.creds_array =
(grpc_call_credentials **)gpr_zalloc(creds_array_byte_size);
for (i = 0; i < creds1_array.num_creds; i++) { for (i = 0; i < creds1_array.num_creds; i++) {
grpc_call_credentials *cur_creds = creds1_array.creds_array[i]; grpc_call_credentials *cur_creds = creds1_array.creds_array[i];
c->inner.creds_array[i] = grpc_call_credentials_ref(cur_creds); c->inner.creds_array[i] = grpc_call_credentials_ref(cur_creds);
@ -248,7 +251,8 @@ static grpc_channel_credentials_vtable composite_channel_credentials_vtable = {
grpc_channel_credentials *grpc_composite_channel_credentials_create( grpc_channel_credentials *grpc_composite_channel_credentials_create(
grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds, grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds,
void *reserved) { void *reserved) {
grpc_composite_channel_credentials *c = (grpc_composite_channel_credentials*) gpr_zalloc(sizeof(*c)); grpc_composite_channel_credentials *c =
(grpc_composite_channel_credentials *)gpr_zalloc(sizeof(*c));
GPR_ASSERT(channel_creds != NULL && call_creds != NULL && reserved == NULL); GPR_ASSERT(channel_creds != NULL && call_creds != NULL && reserved == NULL);
GRPC_API_TRACE( GRPC_API_TRACE(
"grpc_composite_channel_credentials_create(channel_creds=%p, " "grpc_composite_channel_credentials_create(channel_creds=%p, "

@ -40,7 +40,8 @@
grpc_credentials_metadata_request *grpc_credentials_metadata_request_create( grpc_credentials_metadata_request *grpc_credentials_metadata_request_create(
grpc_call_credentials *creds) { grpc_call_credentials *creds) {
grpc_credentials_metadata_request *r = grpc_credentials_metadata_request *r =
gpr_zalloc(sizeof(grpc_credentials_metadata_request)); (grpc_credentials_metadata_request *)gpr_zalloc(
sizeof(grpc_credentials_metadata_request));
r->creds = grpc_call_credentials_ref(creds); r->creds = grpc_call_credentials_ref(creds);
return r; return r;
} }
@ -148,11 +149,11 @@ grpc_channel_credentials_duplicate_without_call_credentials(
} }
static void credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) { static void credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
grpc_channel_credentials_unref(exec_ctx, p); grpc_channel_credentials_unref(exec_ctx, (grpc_channel_credentials *)p);
} }
static void *credentials_pointer_arg_copy(void *p) { static void *credentials_pointer_arg_copy(void *p) {
return grpc_channel_credentials_ref(p); return grpc_channel_credentials_ref((grpc_channel_credentials *)p);
} }
static int credentials_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); } static int credentials_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
@ -163,8 +164,9 @@ static const grpc_arg_pointer_vtable credentials_pointer_vtable = {
grpc_arg grpc_channel_credentials_to_arg( grpc_arg grpc_channel_credentials_to_arg(
grpc_channel_credentials *credentials) { grpc_channel_credentials *credentials) {
return grpc_channel_arg_pointer_create( return grpc_channel_arg_pointer_create((char *)GRPC_ARG_CHANNEL_CREDENTIALS,
GRPC_ARG_CHANNEL_CREDENTIALS, credentials, &credentials_pointer_vtable); credentials,
&credentials_pointer_vtable);
} }
grpc_channel_credentials *grpc_channel_credentials_from_arg( grpc_channel_credentials *grpc_channel_credentials_from_arg(
@ -175,7 +177,7 @@ grpc_channel_credentials *grpc_channel_credentials_from_arg(
GRPC_ARG_CHANNEL_CREDENTIALS); GRPC_ARG_CHANNEL_CREDENTIALS);
return NULL; return NULL;
} }
return arg->value.pointer.p; return (grpc_channel_credentials *)arg->value.pointer.p;
} }
grpc_channel_credentials *grpc_channel_credentials_find_in_args( grpc_channel_credentials *grpc_channel_credentials_find_in_args(
@ -244,11 +246,11 @@ void grpc_server_credentials_set_auth_metadata_processor(
static void server_credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, static void server_credentials_pointer_arg_destroy(grpc_exec_ctx *exec_ctx,
void *p) { void *p) {
grpc_server_credentials_unref(exec_ctx, p); grpc_server_credentials_unref(exec_ctx, (grpc_server_credentials *)p);
} }
static void *server_credentials_pointer_arg_copy(void *p) { static void *server_credentials_pointer_arg_copy(void *p) {
return grpc_server_credentials_ref(p); return grpc_server_credentials_ref((grpc_server_credentials *)p);
} }
static int server_credentials_pointer_cmp(void *a, void *b) { static int server_credentials_pointer_cmp(void *a, void *b) {
@ -260,7 +262,7 @@ static const grpc_arg_pointer_vtable cred_ptr_vtable = {
server_credentials_pointer_cmp}; server_credentials_pointer_cmp};
grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials *p) { grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials *p) {
return grpc_channel_arg_pointer_create(GRPC_SERVER_CREDENTIALS_ARG, p, return grpc_channel_arg_pointer_create((char *)GRPC_SERVER_CREDENTIALS_ARG, p,
&cred_ptr_vtable); &cred_ptr_vtable);
} }
@ -271,7 +273,7 @@ grpc_server_credentials *grpc_server_credentials_from_arg(const grpc_arg *arg) {
GRPC_SERVER_CREDENTIALS_ARG); GRPC_SERVER_CREDENTIALS_ARG);
return NULL; return NULL;
} }
return arg->value.pointer.p; return (grpc_server_credentials *)arg->value.pointer.p;
} }
grpc_server_credentials *grpc_find_server_credentials_in_args( grpc_server_credentials *grpc_find_server_credentials_in_args(

@ -33,7 +33,8 @@ static void mdelem_list_ensure_capacity(grpc_credentials_mdelem_array *list,
while (new_size < target_size) { while (new_size < target_size) {
new_size *= 2; new_size *= 2;
} }
list->md = (grpc_mdelem*) gpr_realloc(list->md, sizeof(grpc_mdelem) * new_size); list->md =
(grpc_mdelem *)gpr_realloc(list->md, sizeof(grpc_mdelem) * new_size);
} }
void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array *list, void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array *list,

@ -60,7 +60,8 @@ static grpc_server_credentials_vtable
grpc_channel_credentials *grpc_fake_transport_security_credentials_create( grpc_channel_credentials *grpc_fake_transport_security_credentials_create(
void) { void) {
grpc_channel_credentials *c = (grpc_channel_credentials*) gpr_zalloc(sizeof(grpc_channel_credentials)); grpc_channel_credentials *c =
(grpc_channel_credentials *)gpr_zalloc(sizeof(grpc_channel_credentials));
c->type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY; c->type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY;
c->vtable = &fake_transport_security_credentials_vtable; c->vtable = &fake_transport_security_credentials_vtable;
gpr_ref_init(&c->refcount, 1); gpr_ref_init(&c->refcount, 1);
@ -69,7 +70,8 @@ grpc_channel_credentials *grpc_fake_transport_security_credentials_create(
grpc_server_credentials *grpc_fake_transport_security_server_credentials_create( grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
void) { void) {
grpc_server_credentials *c = (grpc_server_credentials*) gpr_malloc(sizeof(grpc_server_credentials)); grpc_server_credentials *c =
(grpc_server_credentials *)gpr_malloc(sizeof(grpc_server_credentials));
memset(c, 0, sizeof(grpc_server_credentials)); memset(c, 0, sizeof(grpc_server_credentials));
c->type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY; c->type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY;
gpr_ref_init(&c->refcount, 1); gpr_ref_init(&c->refcount, 1);
@ -78,8 +80,8 @@ grpc_server_credentials *grpc_fake_transport_security_server_credentials_create(
} }
grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets) { grpc_arg grpc_fake_transport_expected_targets_arg(char *expected_targets) {
return grpc_channel_arg_string_create(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, return grpc_channel_arg_string_create(
expected_targets); (char *)GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_targets);
} }
const char *grpc_fake_transport_get_expected_targets( const char *grpc_fake_transport_get_expected_targets(
@ -129,7 +131,8 @@ grpc_call_credentials *grpc_md_only_test_credentials_create(
grpc_exec_ctx *exec_ctx, const char *md_key, const char *md_value, grpc_exec_ctx *exec_ctx, const char *md_key, const char *md_value,
bool is_async) { bool is_async) {
grpc_md_only_test_credentials *c = grpc_md_only_test_credentials *c =
gpr_zalloc(sizeof(grpc_md_only_test_credentials)); (grpc_md_only_test_credentials *)gpr_zalloc(
sizeof(grpc_md_only_test_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2; c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
c->base.vtable = &md_only_test_vtable; c->base.vtable = &md_only_test_vtable;
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.refcount, 1);

@ -85,7 +85,7 @@ static void on_compute_engine_detection_http_response(grpc_exec_ctx *exec_ctx,
} }
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, grpc_error *e) { static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, grpc_error *e) {
grpc_pollset_destroy(exec_ctx, p); grpc_pollset_destroy(exec_ctx, (grpc_pollset *)p);
} }
static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) { static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
@ -106,8 +106,8 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) {
memset(&detector.response, 0, sizeof(detector.response)); memset(&detector.response, 0, sizeof(detector.response));
memset(&request, 0, sizeof(grpc_httpcli_request)); memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = GRPC_COMPUTE_ENGINE_DETECTION_HOST; request.host = (char *)GRPC_COMPUTE_ENGINE_DETECTION_HOST;
request.http.path = "/"; request.http.path = (char *)"/";
grpc_httpcli_context_init(&context); grpc_httpcli_context_init(&context);

@ -64,7 +64,8 @@ grpc_call_credentials *grpc_google_iam_credentials_create(
GPR_ASSERT(reserved == NULL); GPR_ASSERT(reserved == NULL);
GPR_ASSERT(token != NULL); GPR_ASSERT(token != NULL);
GPR_ASSERT(authority_selector != NULL); GPR_ASSERT(authority_selector != NULL);
grpc_google_iam_credentials *c = (grpc_google_iam_credentials*) gpr_zalloc(sizeof(*c)); grpc_google_iam_credentials *c =
(grpc_google_iam_credentials *)gpr_zalloc(sizeof(*c));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_IAM; c->base.type = GRPC_CALL_CREDENTIALS_TYPE_IAM;
c->base.vtable = &iam_vtable; c->base.vtable = &iam_vtable;
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.refcount, 1);

@ -96,7 +96,7 @@ grpc_auth_json_key grpc_auth_json_key_create_from_json(const grpc_json *json) {
gpr_log(GPR_ERROR, "Could not write into openssl BIO."); gpr_log(GPR_ERROR, "Could not write into openssl BIO.");
goto end; goto end;
} }
result.private_key = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, ""); result.private_key = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, (void *)"");
if (result.private_key == NULL) { if (result.private_key == NULL) {
gpr_log(GPR_ERROR, "Could not deserialize private key."); gpr_log(GPR_ERROR, "Could not deserialize private key.");
goto end; goto end;

@ -125,7 +125,8 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
gpr_log(GPR_ERROR, "Invalid input for jwt credentials creation"); gpr_log(GPR_ERROR, "Invalid input for jwt credentials creation");
return NULL; return NULL;
} }
c = (grpc_service_account_jwt_access_credentials*) gpr_zalloc(sizeof(grpc_service_account_jwt_access_credentials)); c = (grpc_service_account_jwt_access_credentials *)gpr_zalloc(
sizeof(grpc_service_account_jwt_access_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_JWT; c->base.type = GRPC_CALL_CREDENTIALS_TYPE_JWT;
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &jwt_vtable; c->base.vtable = &jwt_vtable;

@ -231,7 +231,8 @@ gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims *claims) {
grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_exec_ctx *exec_ctx, grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_exec_ctx *exec_ctx,
grpc_json *json, grpc_slice buffer) { grpc_json *json, grpc_slice buffer) {
grpc_json *cur; grpc_json *cur;
grpc_jwt_claims *claims = (grpc_jwt_claims*) gpr_malloc(sizeof(grpc_jwt_claims)); grpc_jwt_claims *claims =
(grpc_jwt_claims *)gpr_malloc(sizeof(grpc_jwt_claims));
memset(claims, 0, sizeof(grpc_jwt_claims)); memset(claims, 0, sizeof(grpc_jwt_claims));
claims->json = json; claims->json = json;
claims->buffer = buffer; claims->buffer = buffer;
@ -676,6 +677,7 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_json *json = json_from_http(response); grpc_json *json = json_from_http(response);
grpc_httpcli_request req; grpc_httpcli_request req;
const char *jwks_uri; const char *jwks_uri;
grpc_resource_quota *resource_quota = NULL;
/* TODO(jboeuf): Cache the jwks_uri in order to avoid this hop next time. */ /* TODO(jboeuf): Cache the jwks_uri in order to avoid this hop next time. */
if (json == NULL) goto error; if (json == NULL) goto error;
@ -693,9 +695,9 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
jwks_uri += 8; jwks_uri += 8;
req.handshaker = &grpc_httpcli_ssl; req.handshaker = &grpc_httpcli_ssl;
req.host = gpr_strdup(jwks_uri); req.host = gpr_strdup(jwks_uri);
req.http.path = strchr(jwks_uri, '/'); req.http.path = (char *)strchr(jwks_uri, '/');
if (req.http.path == NULL) { if (req.http.path == NULL) {
req.http.path = ""; req.http.path = (char *)"";
} else { } else {
*(req.host + (req.http.path - jwks_uri)) = '\0'; *(req.host + (req.http.path - jwks_uri)) = '\0';
} }
@ -703,8 +705,7 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host /* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */ extreme memory pressure. */
grpc_resource_quota *resource_quota = resource_quota = grpc_resource_quota_create("jwt_verifier");
grpc_resource_quota_create("jwt_verifier");
grpc_httpcli_get( grpc_httpcli_get(
exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req, exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay), gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay),
@ -760,7 +761,7 @@ const char *grpc_jwt_issuer_email_domain(const char *issuer) {
if (dot == NULL || dot == email_domain) return email_domain; if (dot == NULL || dot == email_domain) return email_domain;
GPR_ASSERT(dot > email_domain); GPR_ASSERT(dot > email_domain);
/* There may be a subdomain, we just want the domain. */ /* There may be a subdomain, we just want the domain. */
dot = gpr_memrchr(email_domain, '.', (size_t)(dot - email_domain)); dot = (const char *)gpr_memrchr((void *)email_domain, '.', (size_t)(dot - email_domain));
if (dot == NULL) return email_domain; if (dot == NULL) return email_domain;
return dot + 1; return dot + 1;
} }
@ -773,6 +774,7 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx,
char *path_prefix = NULL; char *path_prefix = NULL;
const char *iss; const char *iss;
grpc_httpcli_request req; grpc_httpcli_request req;
grpc_resource_quota *resource_quota = NULL;
memset(&req, 0, sizeof(grpc_httpcli_request)); memset(&req, 0, sizeof(grpc_httpcli_request));
req.handshaker = &grpc_httpcli_ssl; req.handshaker = &grpc_httpcli_ssl;
http_response_index rsp_idx; http_response_index rsp_idx;
@ -831,8 +833,7 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx,
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host /* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */ extreme memory pressure. */
grpc_resource_quota *resource_quota = resource_quota = grpc_resource_quota_create("jwt_verifier");
grpc_resource_quota_create("jwt_verifier");
grpc_httpcli_get( grpc_httpcli_get(
exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req, exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay), gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay),
@ -901,12 +902,14 @@ error:
grpc_jwt_verifier *grpc_jwt_verifier_create( grpc_jwt_verifier *grpc_jwt_verifier_create(
const grpc_jwt_verifier_email_domain_key_url_mapping *mappings, const grpc_jwt_verifier_email_domain_key_url_mapping *mappings,
size_t num_mappings) { size_t num_mappings) {
grpc_jwt_verifier *v = (grpc_jwt_verifier*) gpr_zalloc(sizeof(grpc_jwt_verifier)); grpc_jwt_verifier *v =
(grpc_jwt_verifier *)gpr_zalloc(sizeof(grpc_jwt_verifier));
grpc_httpcli_context_init(&v->http_ctx); grpc_httpcli_context_init(&v->http_ctx);
/* We know at least of one mapping. */ /* We know at least of one mapping. */
v->allocated_mappings = 1 + num_mappings; v->allocated_mappings = 1 + num_mappings;
v->mappings = (email_key_mapping*) gpr_malloc(v->allocated_mappings * sizeof(email_key_mapping)); v->mappings = (email_key_mapping *)gpr_malloc(v->allocated_mappings *
sizeof(email_key_mapping));
verifier_put_mapping(v, GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN, verifier_put_mapping(v, GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN,
GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX); GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX);
/* User-Provided mappings. */ /* User-Provided mappings. */

@ -359,11 +359,11 @@ static void compute_engine_fetch_oauth2(
grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req, grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req,
grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent, grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent,
grpc_iomgr_cb_func response_cb, gpr_timespec deadline) { grpc_iomgr_cb_func response_cb, gpr_timespec deadline) {
grpc_http_header header = {"Metadata-Flavor", "Google"}; grpc_http_header header = {(char *)"Metadata-Flavor", (char *)"Google"};
grpc_httpcli_request request; grpc_httpcli_request request;
memset(&request, 0, sizeof(grpc_httpcli_request)); memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = GRPC_COMPUTE_ENGINE_METADATA_HOST; request.host = (char *)GRPC_COMPUTE_ENGINE_METADATA_HOST;
request.http.path = GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH; request.http.path = (char *)GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH;
request.http.hdr_count = 1; request.http.hdr_count = 1;
request.http.hdrs = &header; request.http.hdrs = &header;
/* TODO(ctiller): Carry the resource_quota in ctx and share it with the host /* TODO(ctiller): Carry the resource_quota in ctx and share it with the host
@ -381,7 +381,8 @@ static void compute_engine_fetch_oauth2(
grpc_call_credentials *grpc_google_compute_engine_credentials_create( grpc_call_credentials *grpc_google_compute_engine_credentials_create(
void *reserved) { void *reserved) {
grpc_oauth2_token_fetcher_credentials *c = grpc_oauth2_token_fetcher_credentials *c =
gpr_malloc(sizeof(grpc_oauth2_token_fetcher_credentials)); (grpc_oauth2_token_fetcher_credentials *)gpr_malloc(
sizeof(grpc_oauth2_token_fetcher_credentials));
GRPC_API_TRACE("grpc_compute_engine_credentials_create(reserved=%p)", 1, GRPC_API_TRACE("grpc_compute_engine_credentials_create(reserved=%p)", 1,
(reserved)); (reserved));
GPR_ASSERT(reserved == NULL); GPR_ASSERT(reserved == NULL);
@ -412,16 +413,16 @@ static void refresh_token_fetch_oauth2(
grpc_iomgr_cb_func response_cb, gpr_timespec deadline) { grpc_iomgr_cb_func response_cb, gpr_timespec deadline) {
grpc_google_refresh_token_credentials *c = grpc_google_refresh_token_credentials *c =
(grpc_google_refresh_token_credentials *)metadata_req->creds; (grpc_google_refresh_token_credentials *)metadata_req->creds;
grpc_http_header header = {"Content-Type", grpc_http_header header = {(char *)"Content-Type",
"application/x-www-form-urlencoded"}; (char *)"application/x-www-form-urlencoded"};
grpc_httpcli_request request; grpc_httpcli_request request;
char *body = NULL; char *body = NULL;
gpr_asprintf(&body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING, gpr_asprintf(&body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING,
c->refresh_token.client_id, c->refresh_token.client_secret, c->refresh_token.client_id, c->refresh_token.client_secret,
c->refresh_token.refresh_token); c->refresh_token.refresh_token);
memset(&request, 0, sizeof(grpc_httpcli_request)); memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = GRPC_GOOGLE_OAUTH2_SERVICE_HOST; request.host = (char *)GRPC_GOOGLE_OAUTH2_SERVICE_HOST;
request.http.path = GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH; request.http.path = (char *)GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH;
request.http.hdr_count = 1; request.http.hdr_count = 1;
request.http.hdrs = &header; request.http.hdrs = &header;
request.handshaker = &grpc_httpcli_ssl; request.handshaker = &grpc_httpcli_ssl;
@ -447,7 +448,8 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token(
gpr_log(GPR_ERROR, "Invalid input for refresh token credentials creation"); gpr_log(GPR_ERROR, "Invalid input for refresh token credentials creation");
return NULL; return NULL;
} }
c = (grpc_google_refresh_token_credentials*) gpr_zalloc(sizeof(grpc_google_refresh_token_credentials)); c = (grpc_google_refresh_token_credentials *)gpr_zalloc(
sizeof(grpc_google_refresh_token_credentials));
init_oauth2_token_fetcher(&c->base, refresh_token_fetch_oauth2); init_oauth2_token_fetcher(&c->base, refresh_token_fetch_oauth2);
c->base.base.vtable = &refresh_token_vtable; c->base.base.vtable = &refresh_token_vtable;
c->refresh_token = refresh_token; c->refresh_token = refresh_token;
@ -515,7 +517,8 @@ static grpc_call_credentials_vtable access_token_vtable = {
grpc_call_credentials *grpc_access_token_credentials_create( grpc_call_credentials *grpc_access_token_credentials_create(
const char *access_token, void *reserved) { const char *access_token, void *reserved) {
grpc_access_token_credentials *c = grpc_access_token_credentials *c =
gpr_zalloc(sizeof(grpc_access_token_credentials)); (grpc_access_token_credentials *)gpr_zalloc(
sizeof(grpc_access_token_credentials));
GRPC_API_TRACE( GRPC_API_TRACE(
"grpc_access_token_credentials_create(access_token=<redacted>, " "grpc_access_token_credentials_create(access_token=<redacted>, "
"reserved=%p)", "reserved=%p)",

@ -258,7 +258,8 @@ static grpc_call_credentials_vtable plugin_vtable = {
grpc_call_credentials *grpc_metadata_credentials_create_from_plugin( grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
grpc_metadata_credentials_plugin plugin, void *reserved) { grpc_metadata_credentials_plugin plugin, void *reserved) {
grpc_plugin_credentials *c = (grpc_plugin_credentials*) gpr_zalloc(sizeof(*c)); grpc_plugin_credentials *c =
(grpc_plugin_credentials *)gpr_zalloc(sizeof(*c));
GRPC_API_TRACE("grpc_metadata_credentials_create_from_plugin(reserved=%p)", 1, GRPC_API_TRACE("grpc_metadata_credentials_create_from_plugin(reserved=%p)", 1,
(reserved)); (reserved));
GPR_ASSERT(reserved == NULL); GPR_ASSERT(reserved == NULL);

@ -67,7 +67,7 @@ static grpc_security_status ssl_create_security_connector(
return status; return status;
} }
grpc_arg new_arg = grpc_arg new_arg =
grpc_channel_arg_string_create(GRPC_ARG_HTTP2_SCHEME, "https"); grpc_channel_arg_string_create((char *)GRPC_ARG_HTTP2_SCHEME, (char *)"https");
*new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1); *new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1);
return status; return status;
} }
@ -94,7 +94,8 @@ static void ssl_build_config(const char *pem_root_certs,
grpc_channel_credentials *grpc_ssl_credentials_create( grpc_channel_credentials *grpc_ssl_credentials_create(
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
void *reserved) { void *reserved) {
grpc_ssl_credentials *c = (grpc_ssl_credentials*) gpr_zalloc(sizeof(grpc_ssl_credentials)); grpc_ssl_credentials *c =
(grpc_ssl_credentials *)gpr_zalloc(sizeof(grpc_ssl_credentials));
GRPC_API_TRACE( GRPC_API_TRACE(
"grpc_ssl_credentials_create(pem_root_certs=%s, " "grpc_ssl_credentials_create(pem_root_certs=%s, "
"pem_key_cert_pair=%p, " "pem_key_cert_pair=%p, "
@ -145,8 +146,8 @@ static void ssl_build_server_config(
} }
if (num_key_cert_pairs > 0) { if (num_key_cert_pairs > 0) {
GPR_ASSERT(pem_key_cert_pairs != NULL); GPR_ASSERT(pem_key_cert_pairs != NULL);
config->pem_key_cert_pairs = config->pem_key_cert_pairs = (tsi_ssl_pem_key_cert_pair *)gpr_zalloc(
gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair)); num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair));
} }
config->num_key_cert_pairs = num_key_cert_pairs; config->num_key_cert_pairs = num_key_cert_pairs;
for (i = 0; i < num_key_cert_pairs; i++) { for (i = 0; i < num_key_cert_pairs; i++) {
@ -175,8 +176,8 @@ grpc_server_credentials *grpc_ssl_server_credentials_create_ex(
size_t num_key_cert_pairs, size_t num_key_cert_pairs,
grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_client_certificate_request_type client_certificate_request,
void *reserved) { void *reserved) {
grpc_ssl_server_credentials *c = grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)gpr_zalloc(
gpr_zalloc(sizeof(grpc_ssl_server_credentials)); sizeof(grpc_ssl_server_credentials));
GRPC_API_TRACE( GRPC_API_TRACE(
"grpc_ssl_server_credentials_create_ex(" "grpc_ssl_server_credentials_create_ex("
"pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, " "pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, "

@ -93,8 +93,9 @@ static void add_error(grpc_error **combined, grpc_error *error) {
static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *arg, static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *input_error) { grpc_error *input_error) {
grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg; grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg;
grpc_call_element *elem = batch->handler_private.extra_arg; grpc_call_element *elem =
call_data *calld = elem->call_data; (grpc_call_element *)batch->handler_private.extra_arg;
call_data *calld = (call_data *)elem->call_data;
reset_auth_metadata_context(&calld->auth_md_context); reset_auth_metadata_context(&calld->auth_md_context);
grpc_error *error = GRPC_ERROR_REF(input_error); grpc_error *error = GRPC_ERROR_REF(input_error);
if (error == GRPC_ERROR_NONE) { if (error == GRPC_ERROR_NONE) {
@ -163,8 +164,8 @@ static void cancel_get_request_metadata(grpc_exec_ctx *exec_ctx, void *arg,
static void send_security_metadata(grpc_exec_ctx *exec_ctx, static void send_security_metadata(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem, grpc_call_element *elem,
grpc_transport_stream_op_batch *batch) { grpc_transport_stream_op_batch *batch) {
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
channel_data *chand = elem->channel_data; channel_data *chand = (channel_data *)elem->channel_data;
grpc_client_security_context *ctx = grpc_client_security_context *ctx =
(grpc_client_security_context *)batch->payload (grpc_client_security_context *)batch->payload
->context[GRPC_CONTEXT_SECURITY] ->context[GRPC_CONTEXT_SECURITY]
@ -225,8 +226,8 @@ static void send_security_metadata(grpc_exec_ctx *exec_ctx,
static void on_host_checked(grpc_exec_ctx *exec_ctx, void *arg, static void on_host_checked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg; grpc_transport_stream_op_batch *batch = (grpc_transport_stream_op_batch *)arg;
grpc_call_element *elem = batch->handler_private.extra_arg; grpc_call_element *elem = (grpc_call_element *)batch->handler_private.extra_arg;
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
if (error == GRPC_ERROR_NONE) { if (error == GRPC_ERROR_NONE) {
send_security_metadata(exec_ctx, elem, batch); send_security_metadata(exec_ctx, elem, batch);
} else { } else {
@ -264,8 +265,8 @@ static void auth_start_transport_stream_op_batch(
GPR_TIMER_BEGIN("auth_start_transport_stream_op_batch", 0); GPR_TIMER_BEGIN("auth_start_transport_stream_op_batch", 0);
/* grab pointers to our data from the call element */ /* grab pointers to our data from the call element */
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
channel_data *chand = elem->channel_data; channel_data *chand = (channel_data *)elem->channel_data;
if (!batch->cancel_stream) { if (!batch->cancel_stream) {
GPR_ASSERT(batch->payload->context != NULL); GPR_ASSERT(batch->payload->context != NULL);
@ -276,7 +277,9 @@ static void auth_start_transport_stream_op_batch(
grpc_client_security_context_destroy; grpc_client_security_context_destroy;
} }
grpc_client_security_context *sec_ctx = grpc_client_security_context *sec_ctx =
batch->payload->context[GRPC_CONTEXT_SECURITY].value; (grpc_client_security_context *)batch->payload
->context[GRPC_CONTEXT_SECURITY]
.value;
GRPC_AUTH_CONTEXT_UNREF(sec_ctx->auth_context, "client auth filter"); GRPC_AUTH_CONTEXT_UNREF(sec_ctx->auth_context, "client auth filter");
sec_ctx->auth_context = sec_ctx->auth_context =
GRPC_AUTH_CONTEXT_REF(chand->auth_context, "client_auth_filter"); GRPC_AUTH_CONTEXT_REF(chand->auth_context, "client_auth_filter");
@ -339,7 +342,7 @@ static void auth_start_transport_stream_op_batch(
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem, grpc_call_element *elem,
const grpc_call_element_args *args) { const grpc_call_element_args *args) {
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
calld->owning_call = args->call_stack; calld->owning_call = args->call_stack;
calld->call_combiner = args->call_combiner; calld->call_combiner = args->call_combiner;
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
@ -348,7 +351,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx, static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem, grpc_call_element *elem,
grpc_polling_entity *pollent) { grpc_polling_entity *pollent) {
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
calld->pollent = pollent; calld->pollent = pollent;
} }
@ -356,7 +359,7 @@ static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info, const grpc_call_final_info *final_info,
grpc_closure *ignored) { grpc_closure *ignored) {
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
grpc_credentials_mdelem_array_destroy(exec_ctx, &calld->md_array); grpc_credentials_mdelem_array_destroy(exec_ctx, &calld->md_array);
grpc_call_credentials_unref(exec_ctx, calld->creds); grpc_call_credentials_unref(exec_ctx, calld->creds);
if (calld->have_host) { if (calld->have_host) {
@ -386,7 +389,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
} }
/* grab pointers to our data from the channel element */ /* grab pointers to our data from the channel element */
channel_data *chand = elem->channel_data; channel_data *chand = (channel_data *)elem->channel_data;
/* The first and the last filters tend to be implemented differently to /* The first and the last filters tend to be implemented differently to
handle the case that there's no 'next' filter to call on the up or down handle the case that there's no 'next' filter to call on the up or down
@ -406,7 +409,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) { grpc_channel_element *elem) {
/* grab pointers to our data from the channel element */ /* grab pointers to our data from the channel element */
channel_data *chand = elem->channel_data; channel_data *chand = (channel_data *)elem->channel_data;
grpc_channel_security_connector *sc = chand->security_connector; grpc_channel_security_connector *sc = chand->security_connector;
if (sc != NULL) { if (sc != NULL) {
GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "client_auth_filter"); GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "client_auth_filter");

@ -25,19 +25,22 @@
* secure naming purposes. */ * secure naming purposes. */
#define GRPC_ARG_LB_SECURE_NAMING_MAP "grpc.lb_secure_naming_map" #define GRPC_ARG_LB_SECURE_NAMING_MAP "grpc.lb_secure_naming_map"
static void *targets_info_copy(void *p) { return grpc_slice_hash_table_ref(p); } static void *targets_info_copy(void *p) {
return grpc_slice_hash_table_ref((grpc_slice_hash_table *)p);
}
static void targets_info_destroy(grpc_exec_ctx *exec_ctx, void *p) { static void targets_info_destroy(grpc_exec_ctx *exec_ctx, void *p) {
grpc_slice_hash_table_unref(exec_ctx, p); grpc_slice_hash_table_unref(exec_ctx, (grpc_slice_hash_table *)p);
} }
static int targets_info_cmp(void *a, void *b) { static int targets_info_cmp(void *a, void *b) {
return grpc_slice_hash_table_cmp(a, b); return grpc_slice_hash_table_cmp((const grpc_slice_hash_table *)a,
(const grpc_slice_hash_table *)b);
} }
static const grpc_arg_pointer_vtable server_to_balancer_names_vtable = { static const grpc_arg_pointer_vtable server_to_balancer_names_vtable = {
targets_info_copy, targets_info_destroy, targets_info_cmp}; targets_info_copy, targets_info_destroy, targets_info_cmp};
grpc_arg grpc_lb_targets_info_create_channel_arg( grpc_arg grpc_lb_targets_info_create_channel_arg(
grpc_slice_hash_table *targets_info) { grpc_slice_hash_table *targets_info) {
return grpc_channel_arg_pointer_create(GRPC_ARG_LB_SECURE_NAMING_MAP, return grpc_channel_arg_pointer_create((char *)GRPC_ARG_LB_SECURE_NAMING_MAP,
targets_info, targets_info,
&server_to_balancer_names_vtable); &server_to_balancer_names_vtable);
} }
@ -48,7 +51,7 @@ grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
grpc_channel_args_find(args, GRPC_ARG_LB_SECURE_NAMING_MAP); grpc_channel_args_find(args, GRPC_ARG_LB_SECURE_NAMING_MAP);
if (targets_info_arg != NULL) { if (targets_info_arg != NULL) {
GPR_ASSERT(targets_info_arg->type == GRPC_ARG_POINTER); GPR_ASSERT(targets_info_arg->type == GRPC_ARG_POINTER);
return targets_info_arg->value.pointer.p; return (grpc_slice_hash_table *)targets_info_arg->value.pointer.p;
} }
return NULL; return NULL;
} }

@ -200,11 +200,13 @@ void grpc_security_connector_unref(grpc_exec_ctx *exec_ctx,
} }
static void connector_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) { static void connector_pointer_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, "connector_pointer_arg_destroy"); GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, (grpc_security_connector *)p,
"connector_pointer_arg_destroy");
} }
static void *connector_pointer_arg_copy(void *p) { static void *connector_pointer_arg_copy(void *p) {
return GRPC_SECURITY_CONNECTOR_REF(p, "connector_pointer_arg_copy"); return GRPC_SECURITY_CONNECTOR_REF((grpc_security_connector *)p,
"connector_pointer_arg_copy");
} }
static int connector_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); } static int connector_pointer_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
@ -214,8 +216,8 @@ static const grpc_arg_pointer_vtable connector_pointer_vtable = {
connector_pointer_cmp}; connector_pointer_cmp};
grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc) { grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc) {
return grpc_channel_arg_pointer_create(GRPC_ARG_SECURITY_CONNECTOR, sc, return grpc_channel_arg_pointer_create((char *)GRPC_ARG_SECURITY_CONNECTOR,
&connector_pointer_vtable); sc, &connector_pointer_vtable);
} }
grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg) { grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg) {
@ -225,7 +227,7 @@ grpc_security_connector *grpc_security_connector_from_arg(const grpc_arg *arg) {
GRPC_ARG_SECURITY_CONNECTOR); GRPC_ARG_SECURITY_CONNECTOR);
return NULL; return NULL;
} }
return arg->value.pointer.p; return (grpc_security_connector *)arg->value.pointer.p;
} }
grpc_security_connector *grpc_security_connector_find_in_args( grpc_security_connector *grpc_security_connector_find_in_args(
@ -424,7 +426,8 @@ static grpc_security_connector_vtable fake_server_vtable = {
grpc_channel_security_connector *grpc_fake_channel_security_connector_create( grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
grpc_call_credentials *request_metadata_creds, const char *target, grpc_call_credentials *request_metadata_creds, const char *target,
const grpc_channel_args *args) { const grpc_channel_args *args) {
grpc_fake_channel_security_connector *c = (grpc_fake_channel_security_connector*) gpr_zalloc(sizeof(*c)); grpc_fake_channel_security_connector *c =
(grpc_fake_channel_security_connector *)gpr_zalloc(sizeof(*c));
gpr_ref_init(&c->base.base.refcount, 1); gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME; c->base.base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
c->base.base.vtable = &fake_channel_vtable; c->base.base.vtable = &fake_channel_vtable;
@ -443,7 +446,8 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
grpc_server_security_connector *grpc_fake_server_security_connector_create( grpc_server_security_connector *grpc_fake_server_security_connector_create(
void) { void) {
grpc_server_security_connector *c = grpc_server_security_connector *c =
gpr_zalloc(sizeof(grpc_server_security_connector)); (grpc_server_security_connector *)gpr_zalloc(
sizeof(grpc_server_security_connector));
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &fake_server_vtable; c->base.vtable = &fake_server_vtable;
c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME; c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
@ -658,7 +662,8 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context(
while (grpc_auth_property_iterator_next(&it) != NULL) max_num_props++; while (grpc_auth_property_iterator_next(&it) != NULL) max_num_props++;
if (max_num_props > 0) { if (max_num_props > 0) {
peer.properties = (tsi_peer_property*) gpr_malloc(max_num_props * sizeof(tsi_peer_property)); peer.properties = (tsi_peer_property *)gpr_malloc(
max_num_props * sizeof(tsi_peer_property));
it = grpc_auth_context_property_iterator(auth_context); it = grpc_auth_context_property_iterator(auth_context);
while ((prop = grpc_auth_property_iterator_next(&it)) != NULL) { while ((prop = grpc_auth_property_iterator_next(&it)) != NULL) {
if (strcmp(prop->name, GRPC_X509_SAN_PROPERTY_NAME) == 0) { if (strcmp(prop->name, GRPC_X509_SAN_PROPERTY_NAME) == 0) {
@ -804,13 +809,13 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
const char *overridden_target_name, grpc_channel_security_connector **sc) { const char *overridden_target_name, grpc_channel_security_connector **sc) {
size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions(); size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions();
const char **alpn_protocol_strings = const char **alpn_protocol_strings =
gpr_malloc(sizeof(const char *) * num_alpn_protocols); (const char **)gpr_malloc(sizeof(const char *) * num_alpn_protocols);
tsi_result result = TSI_OK; tsi_result result = TSI_OK;
grpc_ssl_channel_security_connector *c; grpc_ssl_channel_security_connector *c;
size_t i; size_t i;
const char *pem_root_certs; const char *pem_root_certs;
char *port; char *port;
bool has_key_cert_pair;
for (i = 0; i < num_alpn_protocols; i++) { for (i = 0; i < num_alpn_protocols; i++) {
alpn_protocol_strings[i] = grpc_chttp2_get_alpn_version_index(i); alpn_protocol_strings[i] = grpc_chttp2_get_alpn_version_index(i);
} }
@ -829,7 +834,8 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
pem_root_certs = config->pem_root_certs; pem_root_certs = config->pem_root_certs;
} }
c = (grpc_ssl_channel_security_connector*) gpr_zalloc(sizeof(grpc_ssl_channel_security_connector)); c = (grpc_ssl_channel_security_connector *)gpr_zalloc(
sizeof(grpc_ssl_channel_security_connector));
gpr_ref_init(&c->base.base.refcount, 1); gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.vtable = &ssl_channel_vtable; c->base.base.vtable = &ssl_channel_vtable;
@ -845,7 +851,7 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
c->overridden_target_name = gpr_strdup(overridden_target_name); c->overridden_target_name = gpr_strdup(overridden_target_name);
} }
bool has_key_cert_pair = config->pem_key_cert_pair.private_key != NULL && has_key_cert_pair = config->pem_key_cert_pair.private_key != NULL &&
config->pem_key_cert_pair.cert_chain != NULL; config->pem_key_cert_pair.cert_chain != NULL;
result = tsi_create_ssl_client_handshaker_factory( result = tsi_create_ssl_client_handshaker_factory(
has_key_cert_pair ? &config->pem_key_cert_pair : NULL, pem_root_certs, has_key_cert_pair ? &config->pem_key_cert_pair : NULL, pem_root_certs,
@ -872,7 +878,7 @@ grpc_security_status grpc_ssl_server_security_connector_create(
grpc_server_security_connector **sc) { grpc_server_security_connector **sc) {
size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions(); size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions();
const char **alpn_protocol_strings = const char **alpn_protocol_strings =
gpr_malloc(sizeof(const char *) * num_alpn_protocols); (const char **)gpr_malloc(sizeof(const char *) * num_alpn_protocols);
tsi_result result = TSI_OK; tsi_result result = TSI_OK;
grpc_ssl_server_security_connector *c; grpc_ssl_server_security_connector *c;
size_t i; size_t i;
@ -885,7 +891,8 @@ grpc_security_status grpc_ssl_server_security_connector_create(
gpr_log(GPR_ERROR, "An SSL server needs a key and a cert."); gpr_log(GPR_ERROR, "An SSL server needs a key and a cert.");
goto error; goto error;
} }
c = (grpc_ssl_server_security_connector*) gpr_zalloc(sizeof(grpc_ssl_server_security_connector)); c = (grpc_ssl_server_security_connector *)gpr_zalloc(
sizeof(grpc_ssl_server_security_connector));
gpr_ref_init(&c->base.base.refcount, 1); gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.url_scheme = GRPC_SSL_URL_SCHEME; c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;

@ -63,8 +63,8 @@ static grpc_metadata_array metadata_batch_to_md_array(
grpc_slice value = GRPC_MDVALUE(md); grpc_slice value = GRPC_MDVALUE(md);
if (result.count == result.capacity) { if (result.count == result.capacity) {
result.capacity = GPR_MAX(result.capacity + 8, result.capacity * 2); result.capacity = GPR_MAX(result.capacity + 8, result.capacity * 2);
result.metadata = result.metadata = (grpc_metadata *)gpr_realloc(
gpr_realloc(result.metadata, result.capacity * sizeof(grpc_metadata)); result.metadata, result.capacity * sizeof(grpc_metadata));
} }
usr_md = &result.metadata[result.count++]; usr_md = &result.metadata[result.count++];
usr_md->key = grpc_slice_ref_internal(key); usr_md->key = grpc_slice_ref_internal(key);
@ -76,8 +76,8 @@ static grpc_metadata_array metadata_batch_to_md_array(
static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx *exec_ctx, static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx *exec_ctx,
void *user_data, void *user_data,
grpc_mdelem md) { grpc_mdelem md) {
grpc_call_element *elem = user_data; grpc_call_element *elem = (grpc_call_element *)user_data;
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
size_t i; size_t i;
for (i = 0; i < calld->num_consumed_md; i++) { for (i = 0; i < calld->num_consumed_md; i++) {
const grpc_metadata *consumed_md = &calld->consumed_md[i]; const grpc_metadata *consumed_md = &calld->consumed_md[i];
@ -95,7 +95,7 @@ static void on_md_processing_done_inner(grpc_exec_ctx *exec_ctx,
const grpc_metadata *response_md, const grpc_metadata *response_md,
size_t num_response_md, size_t num_response_md,
grpc_error *error) { grpc_error *error) {
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
grpc_transport_stream_op_batch *batch = calld->recv_initial_metadata_batch; grpc_transport_stream_op_batch *batch = calld->recv_initial_metadata_batch;
/* TODO(jboeuf): Implement support for response_md. */ /* TODO(jboeuf): Implement support for response_md. */
if (response_md != NULL && num_response_md > 0) { if (response_md != NULL && num_response_md > 0) {
@ -119,8 +119,8 @@ static void on_md_processing_done(
void *user_data, const grpc_metadata *consumed_md, size_t num_consumed_md, void *user_data, const grpc_metadata *consumed_md, size_t num_consumed_md,
const grpc_metadata *response_md, size_t num_response_md, const grpc_metadata *response_md, size_t num_response_md,
grpc_status_code status, const char *error_details) { grpc_status_code status, const char *error_details) {
grpc_call_element *elem = user_data; grpc_call_element *elem = (grpc_call_element *)user_data;
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
// If the call was not cancelled while we were in flight, process the result. // If the call was not cancelled while we were in flight, process the result.
if (gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT, if (gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
@ -149,7 +149,7 @@ static void on_md_processing_done(
static void cancel_call(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { static void cancel_call(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
grpc_call_element *elem = (grpc_call_element *)arg; grpc_call_element *elem = (grpc_call_element *)arg;
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
// If the result was not already processed, invoke the callback now. // If the result was not already processed, invoke the callback now.
if (error != GRPC_ERROR_NONE && if (error != GRPC_ERROR_NONE &&
gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT, gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
@ -163,8 +163,8 @@ static void cancel_call(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg, static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
grpc_call_element *elem = (grpc_call_element *)arg; grpc_call_element *elem = (grpc_call_element *)arg;
channel_data *chand = elem->channel_data; channel_data *chand = (channel_data *)elem->channel_data;
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
grpc_transport_stream_op_batch *batch = calld->recv_initial_metadata_batch; grpc_transport_stream_op_batch *batch = calld->recv_initial_metadata_batch;
if (error == GRPC_ERROR_NONE) { if (error == GRPC_ERROR_NONE) {
if (chand->creds != NULL && chand->creds->processor.process != NULL) { if (chand->creds != NULL && chand->creds->processor.process != NULL) {
@ -191,7 +191,7 @@ static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg,
static void auth_start_transport_stream_op_batch( static void auth_start_transport_stream_op_batch(
grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_transport_stream_op_batch *batch) { grpc_transport_stream_op_batch *batch) {
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
if (batch->recv_initial_metadata) { if (batch->recv_initial_metadata) {
// Inject our callback. // Inject our callback.
calld->recv_initial_metadata_batch = batch; calld->recv_initial_metadata_batch = batch;
@ -207,8 +207,8 @@ static void auth_start_transport_stream_op_batch(
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem, grpc_call_element *elem,
const grpc_call_element_args *args) { const grpc_call_element_args *args) {
call_data *calld = elem->call_data; call_data *calld = (call_data *)elem->call_data;
channel_data *chand = elem->channel_data; channel_data *chand = (channel_data *)elem->channel_data;
calld->call_combiner = args->call_combiner; calld->call_combiner = args->call_combiner;
calld->owning_call = args->call_stack; calld->owning_call = args->call_stack;
GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready, GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
@ -240,7 +240,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem, grpc_channel_element *elem,
grpc_channel_element_args *args) { grpc_channel_element_args *args) {
GPR_ASSERT(!args->is_last); GPR_ASSERT(!args->is_last);
channel_data *chand = elem->channel_data; channel_data *chand = (channel_data *)elem->channel_data;
grpc_auth_context *auth_context = grpc_auth_context *auth_context =
grpc_find_auth_context_in_args(args->channel_args); grpc_find_auth_context_in_args(args->channel_args);
GPR_ASSERT(auth_context != NULL); GPR_ASSERT(auth_context != NULL);
@ -255,7 +255,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
/* Destructor for channel data */ /* Destructor for channel data */
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) { grpc_channel_element *elem) {
channel_data *chand = elem->channel_data; channel_data *chand = (channel_data *)elem->channel_data;
GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "server_auth_filter"); GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "server_auth_filter");
grpc_server_credentials_unref(exec_ctx, chand->creds); grpc_server_credentials_unref(exec_ctx, chand->creds);
} }

@ -98,11 +98,11 @@ static const char *tsi_fake_handshake_message_to_string(int msg) {
static tsi_result tsi_fake_handshake_message_from_string( static tsi_result tsi_fake_handshake_message_from_string(
const char *msg_string, tsi_fake_handshake_message *msg) { const char *msg_string, tsi_fake_handshake_message *msg) {
tsi_fake_handshake_message i; int i;
for (i = 0; i < TSI_FAKE_HANDSHAKE_MESSAGE_MAX; i++) { for (i = 0; i < TSI_FAKE_HANDSHAKE_MESSAGE_MAX; i++) {
if (strncmp(msg_string, tsi_fake_handshake_message_strings[i], if (strncmp(msg_string, tsi_fake_handshake_message_strings[i],
strlen(tsi_fake_handshake_message_strings[i])) == 0) { strlen(tsi_fake_handshake_message_strings[i])) == 0) {
*msg = i; *msg = (tsi_fake_handshake_message) i;
return TSI_OK; return TSI_OK;
} }
} }
@ -157,7 +157,8 @@ static void tsi_fake_frame_ensure_size(tsi_fake_frame *frame) {
frame->allocated_size = frame->size; frame->allocated_size = frame->size;
frame->data = (unsigned char *)gpr_malloc(frame->allocated_size); frame->data = (unsigned char *)gpr_malloc(frame->allocated_size);
} else if (frame->size > frame->allocated_size) { } else if (frame->size > frame->allocated_size) {
unsigned char *new_data = (unsigned char*) gpr_realloc(frame->data, frame->size); unsigned char *new_data =
(unsigned char *)gpr_realloc(frame->data, frame->size);
frame->data = new_data; frame->data = new_data;
frame->allocated_size = frame->size; frame->allocated_size = frame->size;
} }
@ -538,7 +539,8 @@ static tsi_result fake_handshaker_result_create(
handshaker_result == NULL) { handshaker_result == NULL) {
return TSI_INVALID_ARGUMENT; return TSI_INVALID_ARGUMENT;
} }
fake_handshaker_result *result = (fake_handshaker_result*) gpr_zalloc(sizeof(*result)); fake_handshaker_result *result =
(fake_handshaker_result *)gpr_zalloc(sizeof(*result));
result->base.vtable = &handshaker_result_vtable; result->base.vtable = &handshaker_result_vtable;
if (unused_bytes_size > 0) { if (unused_bytes_size > 0) {
result->unused_bytes = (unsigned char *)gpr_malloc(unused_bytes_size); result->unused_bytes = (unsigned char *)gpr_malloc(unused_bytes_size);
@ -561,7 +563,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
} }
if (!impl->outgoing_frame.needs_draining) { if (!impl->outgoing_frame.needs_draining) {
tsi_fake_handshake_message next_message_to_send = tsi_fake_handshake_message next_message_to_send =
impl->next_message_to_send + 2; (tsi_fake_handshake_message)(impl->next_message_to_send + 2);
const char *msg_string = const char *msg_string =
tsi_fake_handshake_message_to_string(impl->next_message_to_send); tsi_fake_handshake_message_to_string(impl->next_message_to_send);
result = tsi_fake_frame_set_data((unsigned char *)msg_string, result = tsi_fake_frame_set_data((unsigned char *)msg_string,
@ -596,7 +598,8 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
tsi_handshaker *self, const unsigned char *bytes, size_t *bytes_size) { tsi_handshaker *self, const unsigned char *bytes, size_t *bytes_size) {
tsi_result result = TSI_OK; tsi_result result = TSI_OK;
tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self; tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
tsi_fake_handshake_message expected_msg = impl->next_message_to_send - 1; tsi_fake_handshake_message expected_msg =
(tsi_fake_handshake_message)(impl->next_message_to_send - 1);
tsi_fake_handshake_message received_msg; tsi_fake_handshake_message received_msg;
if (!impl->needs_incoming_message || impl->result == TSI_OK) { if (!impl->needs_incoming_message || impl->result == TSI_OK) {
@ -681,7 +684,7 @@ static tsi_result fake_handshaker_next(
if (result == TSI_INCOMPLETE_DATA) { if (result == TSI_INCOMPLETE_DATA) {
handshaker->outgoing_bytes_buffer_size *= 2; handshaker->outgoing_bytes_buffer_size *= 2;
handshaker->outgoing_bytes_buffer = handshaker->outgoing_bytes_buffer =
gpr_realloc(handshaker->outgoing_bytes_buffer, (unsigned char *)gpr_realloc(handshaker->outgoing_bytes_buffer,
handshaker->outgoing_bytes_buffer_size); handshaker->outgoing_bytes_buffer_size);
} }
} while (result == TSI_INCOMPLETE_DATA); } while (result == TSI_INCOMPLETE_DATA);
@ -729,7 +732,8 @@ tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
impl->result = TSI_HANDSHAKE_IN_PROGRESS; impl->result = TSI_HANDSHAKE_IN_PROGRESS;
impl->outgoing_bytes_buffer_size = impl->outgoing_bytes_buffer_size =
TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE; TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE;
impl->outgoing_bytes_buffer = (unsigned char*) gpr_malloc(impl->outgoing_bytes_buffer_size); impl->outgoing_bytes_buffer =
(unsigned char *)gpr_malloc(impl->outgoing_bytes_buffer_size);
if (is_client) { if (is_client) {
impl->needs_incoming_message = 0; impl->needs_incoming_message = 0;
impl->next_message_to_send = TSI_FAKE_CLIENT_INIT; impl->next_message_to_send = TSI_FAKE_CLIENT_INIT;
@ -742,7 +746,8 @@ tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
tsi_frame_protector *tsi_create_fake_frame_protector( tsi_frame_protector *tsi_create_fake_frame_protector(
size_t *max_protected_frame_size) { size_t *max_protected_frame_size) {
tsi_fake_frame_protector *impl = (tsi_fake_frame_protector*) gpr_zalloc(sizeof(*impl)); tsi_fake_frame_protector *impl =
(tsi_fake_frame_protector *)gpr_zalloc(sizeof(*impl));
impl->max_frame_size = (max_protected_frame_size == NULL) impl->max_frame_size = (max_protected_frame_size == NULL)
? TSI_FAKE_DEFAULT_FRAME_SIZE ? TSI_FAKE_DEFAULT_FRAME_SIZE
: *max_protected_frame_size; : *max_protected_frame_size;
@ -752,7 +757,8 @@ tsi_frame_protector *tsi_create_fake_frame_protector(
tsi_zero_copy_grpc_protector *tsi_create_fake_zero_copy_grpc_protector( tsi_zero_copy_grpc_protector *tsi_create_fake_zero_copy_grpc_protector(
size_t *max_protected_frame_size) { size_t *max_protected_frame_size) {
tsi_fake_zero_copy_grpc_protector *impl = (tsi_fake_zero_copy_grpc_protector*) gpr_zalloc(sizeof(*impl)); tsi_fake_zero_copy_grpc_protector *impl =
(tsi_fake_zero_copy_grpc_protector *)gpr_zalloc(sizeof(*impl));
grpc_slice_buffer_init(&impl->header_sb); grpc_slice_buffer_init(&impl->header_sb);
grpc_slice_buffer_init(&impl->protected_sb); grpc_slice_buffer_init(&impl->protected_sb);
impl->max_frame_size = (max_protected_frame_size == NULL) impl->max_frame_size = (max_protected_frame_size == NULL)

@ -361,7 +361,7 @@ static tsi_result peer_from_x509(X509 *cert, int include_certificate_type,
tsi_peer *peer) { tsi_peer *peer) {
/* TODO(jboeuf): Maybe add more properties. */ /* TODO(jboeuf): Maybe add more properties. */
GENERAL_NAMES *subject_alt_names = GENERAL_NAMES *subject_alt_names =
X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0); (GENERAL_NAMES *)X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0);
int subject_alt_name_count = (subject_alt_names != NULL) int subject_alt_name_count = (subject_alt_names != NULL)
? (int)sk_GENERAL_NAME_num(subject_alt_names) ? (int)sk_GENERAL_NAME_num(subject_alt_names)
: 0; : 0;
@ -479,7 +479,7 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX *context,
if (pem == NULL) return TSI_OUT_OF_RESOURCES; if (pem == NULL) return TSI_OUT_OF_RESOURCES;
do { do {
certificate = PEM_read_bio_X509_AUX(pem, NULL, NULL, ""); certificate = PEM_read_bio_X509_AUX(pem, NULL, NULL, (void *)"");
if (certificate == NULL) { if (certificate == NULL) {
result = TSI_INVALID_ARGUMENT; result = TSI_INVALID_ARGUMENT;
break; break;
@ -489,7 +489,8 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX *context,
break; break;
} }
while (1) { while (1) {
X509 *certificate_authority = PEM_read_bio_X509(pem, NULL, NULL, ""); X509 *certificate_authority =
PEM_read_bio_X509(pem, NULL, NULL, (void *)"");
if (certificate_authority == NULL) { if (certificate_authority == NULL) {
ERR_clear_error(); ERR_clear_error();
break; /* Done reading. */ break; /* Done reading. */
@ -520,7 +521,7 @@ static tsi_result ssl_ctx_use_private_key(SSL_CTX *context, const char *pem_key,
pem = BIO_new_mem_buf((void *)pem_key, (int)pem_key_size); pem = BIO_new_mem_buf((void *)pem_key, (int)pem_key_size);
if (pem == NULL) return TSI_OUT_OF_RESOURCES; if (pem == NULL) return TSI_OUT_OF_RESOURCES;
do { do {
private_key = PEM_read_bio_PrivateKey(pem, NULL, NULL, ""); private_key = PEM_read_bio_PrivateKey(pem, NULL, NULL, (void *)"");
if (private_key == NULL) { if (private_key == NULL) {
result = TSI_INVALID_ARGUMENT; result = TSI_INVALID_ARGUMENT;
break; break;
@ -559,7 +560,7 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX *context,
} }
while (1) { while (1) {
root = PEM_read_bio_X509_AUX(pem, NULL, NULL, ""); root = PEM_read_bio_X509_AUX(pem, NULL, NULL, (void *)"");
if (root == NULL) { if (root == NULL) {
ERR_clear_error(); ERR_clear_error();
break; /* We're at the end of stream. */ break; /* We're at the end of stream. */
@ -655,7 +656,7 @@ static tsi_result extract_x509_subject_names_from_pem_cert(const char *pem_cert,
pem = BIO_new_mem_buf((void *)pem_cert, (int)strlen(pem_cert)); pem = BIO_new_mem_buf((void *)pem_cert, (int)strlen(pem_cert));
if (pem == NULL) return TSI_OUT_OF_RESOURCES; if (pem == NULL) return TSI_OUT_OF_RESOURCES;
cert = PEM_read_bio_X509(pem, NULL, NULL, ""); cert = PEM_read_bio_X509(pem, NULL, NULL, (void *)"");
if (cert == NULL) { if (cert == NULL) {
gpr_log(GPR_ERROR, "Invalid certificate"); gpr_log(GPR_ERROR, "Invalid certificate");
result = TSI_INVALID_ARGUMENT; result = TSI_INVALID_ARGUMENT;
@ -998,8 +999,8 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker *self,
} }
if (alpn_selected != NULL) { if (alpn_selected != NULL) {
size_t i; size_t i;
tsi_peer_property *new_properties = tsi_peer_property *new_properties = (tsi_peer_property *)gpr_zalloc(
gpr_zalloc(sizeof(*new_properties) * (peer->property_count + 1)); sizeof(*new_properties) * (peer->property_count + 1));
for (i = 0; i < peer->property_count; i++) { for (i = 0; i < peer->property_count; i++) {
new_properties[i] = peer->properties[i]; new_properties[i] = peer->properties[i];
} }
@ -1023,7 +1024,8 @@ static tsi_result ssl_handshaker_create_frame_protector(
size_t actual_max_output_protected_frame_size = size_t actual_max_output_protected_frame_size =
TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND; TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND;
tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self; tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
tsi_ssl_frame_protector *protector_impl = (tsi_ssl_frame_protector*) gpr_zalloc(sizeof(*protector_impl)); tsi_ssl_frame_protector *protector_impl =
(tsi_ssl_frame_protector *)gpr_zalloc(sizeof(*protector_impl));
if (max_output_protected_frame_size != NULL) { if (max_output_protected_frame_size != NULL) {
if (*max_output_protected_frame_size > if (*max_output_protected_frame_size >
@ -1039,7 +1041,8 @@ static tsi_result ssl_handshaker_create_frame_protector(
} }
protector_impl->buffer_size = protector_impl->buffer_size =
actual_max_output_protected_frame_size - TSI_SSL_MAX_PROTECTION_OVERHEAD; actual_max_output_protected_frame_size - TSI_SSL_MAX_PROTECTION_OVERHEAD;
protector_impl->buffer = (unsigned char*) gpr_malloc(protector_impl->buffer_size); protector_impl->buffer =
(unsigned char *)gpr_malloc(protector_impl->buffer_size);
if (protector_impl->buffer == NULL) { if (protector_impl->buffer == NULL) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"Could not allocated buffer for tsi_ssl_frame_protector."); "Could not allocated buffer for tsi_ssl_frame_protector.");
@ -1448,9 +1451,10 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
tsi_ssl_handshaker_factory_init(&impl->base); tsi_ssl_handshaker_factory_init(&impl->base);
impl->base.vtable = &server_handshaker_factory_vtable; impl->base.vtable = &server_handshaker_factory_vtable;
impl->ssl_contexts = (SSL_CTX**) gpr_zalloc(num_key_cert_pairs * sizeof(SSL_CTX *)); impl->ssl_contexts =
(SSL_CTX **)gpr_zalloc(num_key_cert_pairs * sizeof(SSL_CTX *));
impl->ssl_context_x509_subject_names = impl->ssl_context_x509_subject_names =
gpr_zalloc(num_key_cert_pairs * sizeof(tsi_peer)); (tsi_peer *)gpr_zalloc(num_key_cert_pairs * sizeof(tsi_peer));
if (impl->ssl_contexts == NULL || if (impl->ssl_contexts == NULL ||
impl->ssl_context_x509_subject_names == NULL) { impl->ssl_context_x509_subject_names == NULL) {
tsi_ssl_handshaker_factory_unref(&impl->base); tsi_ssl_handshaker_factory_unref(&impl->base);

@ -310,7 +310,8 @@ tsi_result tsi_construct_string_peer_property(const char *name,
tsi_result tsi_construct_peer(size_t property_count, tsi_peer *peer) { tsi_result tsi_construct_peer(size_t property_count, tsi_peer *peer) {
memset(peer, 0, sizeof(tsi_peer)); memset(peer, 0, sizeof(tsi_peer));
if (property_count > 0) { if (property_count > 0) {
peer->properties = (tsi_peer_property*) gpr_zalloc(property_count * sizeof(tsi_peer_property)); peer->properties = (tsi_peer_property *)gpr_zalloc(
property_count * sizeof(tsi_peer_property));
peer->property_count = property_count; peer->property_count = property_count;
} }
return TSI_OK; return TSI_OK;

@ -80,7 +80,8 @@ static tsi_result tsi_adapter_create_handshaker_result(
if (wrapped == NULL || (unused_bytes_size > 0 && unused_bytes == NULL)) { if (wrapped == NULL || (unused_bytes_size > 0 && unused_bytes == NULL)) {
return TSI_INVALID_ARGUMENT; return TSI_INVALID_ARGUMENT;
} }
tsi_adapter_handshaker_result *impl = (tsi_adapter_handshaker_result*) gpr_zalloc(sizeof(*impl)); tsi_adapter_handshaker_result *impl =
(tsi_adapter_handshaker_result *)gpr_zalloc(sizeof(*impl));
impl->base.vtable = &result_vtable; impl->base.vtable = &result_vtable;
impl->wrapped = wrapped; impl->wrapped = wrapped;
impl->unused_bytes_size = unused_bytes_size; impl->unused_bytes_size = unused_bytes_size;
@ -172,8 +173,8 @@ static tsi_result adapter_next(
offset += to_send_size; offset += to_send_size;
if (status == TSI_INCOMPLETE_DATA) { if (status == TSI_INCOMPLETE_DATA) {
impl->adapter_buffer_size *= 2; impl->adapter_buffer_size *= 2;
impl->adapter_buffer = impl->adapter_buffer = (unsigned char *)gpr_realloc(
gpr_realloc(impl->adapter_buffer, impl->adapter_buffer_size); impl->adapter_buffer, impl->adapter_buffer_size);
} }
} while (status == TSI_INCOMPLETE_DATA); } while (status == TSI_INCOMPLETE_DATA);
if (status != TSI_OK) return status; if (status != TSI_OK) return status;
@ -209,7 +210,8 @@ static const tsi_handshaker_vtable handshaker_vtable = {
tsi_handshaker *tsi_create_adapter_handshaker(tsi_handshaker *wrapped) { tsi_handshaker *tsi_create_adapter_handshaker(tsi_handshaker *wrapped) {
GPR_ASSERT(wrapped != NULL); GPR_ASSERT(wrapped != NULL);
tsi_adapter_handshaker *impl = (tsi_adapter_handshaker*) gpr_zalloc(sizeof(*impl)); tsi_adapter_handshaker *impl =
(tsi_adapter_handshaker *)gpr_zalloc(sizeof(*impl));
impl->base.vtable = &handshaker_vtable; impl->base.vtable = &handshaker_vtable;
impl->wrapped = wrapped; impl->wrapped = wrapped;
impl->adapter_buffer_size = TSI_ADAPTER_INITIAL_BUFFER_SIZE; impl->adapter_buffer_size = TSI_ADAPTER_INITIAL_BUFFER_SIZE;

Loading…
Cancel
Save