diff options
author | Craig Tiller <ctiller@google.com> | 2017-10-05 10:28:15 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-10-05 10:28:15 -0700 |
commit | 529102373061d599f861528e180bfdc2860f6b5f (patch) | |
tree | 2e4fc843fa7a093e3128fccddbbe795136f91acc /src/core/lib/security/credentials | |
parent | 76eab735f41baf8dd8af6524a8ce673a5803f5d4 (diff) | |
parent | c277fc0818eb2e7408db6758c9690bb4eb2c6ff7 (diff) |
Merge github.com:grpc/grpc into flowctl+millis
Diffstat (limited to 'src/core/lib/security/credentials')
21 files changed, 158 insertions, 63 deletions
diff --git a/src/core/lib/security/credentials/composite/composite_credentials.c b/src/core/lib/security/credentials/composite/composite_credentials.cc index b67ff48d0f..779300ac07 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.c +++ b/src/core/lib/security/credentials/composite/composite_credentials.cc @@ -79,7 +79,8 @@ static bool composite_call_get_request_metadata( grpc_error **error) { grpc_composite_call_credentials *c = (grpc_composite_call_credentials *)creds; grpc_composite_call_credentials_metadata_context *ctx; - ctx = 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->pollent = pollent; 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(creds1 != NULL); GPR_ASSERT(creds2 != NULL); - c = 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.vtable = &composite_call_credentials_vtable; 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); c->inner.num_creds = creds1_array.num_creds + creds2_array.num_creds; creds_array_byte_size = c->inner.num_creds * sizeof(grpc_call_credentials *); - c->inner.creds_array = 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++) { grpc_call_credentials *cur_creds = creds1_array.creds_array[i]; 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 *channel_creds, grpc_call_credentials *call_creds, void *reserved) { - grpc_composite_channel_credentials *c = 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); GRPC_API_TRACE( "grpc_composite_channel_credentials_create(channel_creds=%p, " diff --git a/src/core/lib/security/credentials/composite/composite_credentials.h b/src/core/lib/security/credentials/composite/composite_credentials.h index 3076afcb7e..6e9f9a8f6f 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.h +++ b/src/core/lib/security/credentials/composite/composite_credentials.h @@ -21,6 +21,10 @@ #include "src/core/lib/security/credentials/credentials.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { grpc_call_credentials **creds_array; size_t num_creds; @@ -53,5 +57,9 @@ typedef struct { grpc_call_credentials_array inner; } grpc_composite_call_credentials; +#ifdef __cplusplus +} +#endif + #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H \ */ diff --git a/src/core/lib/security/credentials/credentials.c b/src/core/lib/security/credentials/credentials.cc index 8a67c9865b..ebbf350865 100644 --- a/src/core/lib/security/credentials/credentials.c +++ b/src/core/lib/security/credentials/credentials.cc @@ -40,7 +40,8 @@ grpc_credentials_metadata_request *grpc_credentials_metadata_request_create( grpc_call_credentials *creds) { 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); 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) { - 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) { - 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); } @@ -163,8 +164,9 @@ static const grpc_arg_pointer_vtable credentials_pointer_vtable = { grpc_arg grpc_channel_credentials_to_arg( grpc_channel_credentials *credentials) { - return grpc_channel_arg_pointer_create( - GRPC_ARG_CHANNEL_CREDENTIALS, credentials, &credentials_pointer_vtable); + return grpc_channel_arg_pointer_create((char *)GRPC_ARG_CHANNEL_CREDENTIALS, + credentials, + &credentials_pointer_vtable); } grpc_channel_credentials *grpc_channel_credentials_from_arg( @@ -175,7 +177,7 @@ grpc_channel_credentials *grpc_channel_credentials_from_arg( GRPC_ARG_CHANNEL_CREDENTIALS); return NULL; } - return arg->value.pointer.p; + return (grpc_channel_credentials *)arg->value.pointer.p; } 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, 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) { - 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) { @@ -260,7 +262,7 @@ static const grpc_arg_pointer_vtable cred_ptr_vtable = { server_credentials_pointer_cmp}; 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); } @@ -271,7 +273,7 @@ grpc_server_credentials *grpc_server_credentials_from_arg(const grpc_arg *arg) { GRPC_SERVER_CREDENTIALS_ARG); return NULL; } - return arg->value.pointer.p; + return (grpc_server_credentials *)arg->value.pointer.p; } grpc_server_credentials *grpc_find_server_credentials_in_args( diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index 04a54b0ca8..73e39ae039 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -29,6 +29,10 @@ #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/security/transport/security_connector.h" +#ifdef __cplusplus +extern "C" { +#endif + struct grpc_http_response; /* --- Constants. --- */ @@ -252,4 +256,8 @@ grpc_credentials_metadata_request *grpc_credentials_metadata_request_create( void grpc_credentials_metadata_request_destroy( grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *r); +#ifdef __cplusplus +} +#endif + #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H */ diff --git a/src/core/lib/security/credentials/credentials_metadata.c b/src/core/lib/security/credentials/credentials_metadata.cc index ccd39e610f..5ba98bda4e 100644 --- a/src/core/lib/security/credentials/credentials_metadata.c +++ b/src/core/lib/security/credentials/credentials_metadata.cc @@ -33,7 +33,8 @@ static void mdelem_list_ensure_capacity(grpc_credentials_mdelem_array *list, while (new_size < target_size) { new_size *= 2; } - list->md = 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, diff --git a/src/core/lib/security/credentials/fake/fake_credentials.c b/src/core/lib/security/credentials/fake/fake_credentials.cc index ac9017850f..795ca0660a 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.c +++ b/src/core/lib/security/credentials/fake/fake_credentials.cc @@ -60,7 +60,8 @@ static grpc_server_credentials_vtable grpc_channel_credentials *grpc_fake_transport_security_credentials_create( void) { - grpc_channel_credentials *c = 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->vtable = &fake_transport_security_credentials_vtable; 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( void) { - grpc_server_credentials *c = 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)); c->type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY; 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) { - return grpc_channel_arg_string_create(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, - expected_targets); + return grpc_channel_arg_string_create( + (char *)GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, 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, bool is_async) { 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.vtable = &md_only_test_vtable; gpr_ref_init(&c->base.refcount, 1); diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h index aa0f3b6e20..64f6f439f0 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.h +++ b/src/core/lib/security/credentials/fake/fake_credentials.h @@ -21,6 +21,10 @@ #include "src/core/lib/security/credentials/credentials.h" +#ifdef __cplusplus +extern "C" { +#endif + /* -- Fake transport security credentials. -- */ /* Creates a fake transport security credentials object for testing. */ @@ -56,4 +60,8 @@ typedef struct { bool is_async; } grpc_md_only_test_credentials; -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */ +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */
\ No newline at end of file diff --git a/src/core/lib/security/credentials/google_default/credentials_generic.c b/src/core/lib/security/credentials/google_default/credentials_generic.cc index 4f79718f3d..4f79718f3d 100644 --- a/src/core/lib/security/credentials/google_default/credentials_generic.c +++ b/src/core/lib/security/credentials/google_default/credentials_generic.cc diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.c b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index 0877818291..5b2ddceb4a 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.c +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -28,6 +28,7 @@ #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/iomgr/polling_entity.h" +#include "src/core/lib/security/credentials/google_default/google_default_credentials.h" #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" #include "src/core/lib/slice/slice_internal.h" @@ -85,7 +86,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) { - 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) { @@ -98,7 +99,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) { on compute engine. */ grpc_millis max_detection_delay = GPR_MS_PER_SEC; - grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size()); + grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(pollset, &g_polling_mu); detector.pollent = grpc_polling_entity_create_from_pollset(pollset); detector.is_done = 0; @@ -106,8 +107,8 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) { memset(&detector.response, 0, sizeof(detector.response)); memset(&request, 0, sizeof(grpc_httpcli_request)); - request.host = GRPC_COMPUTE_ENGINE_DETECTION_HOST; - request.http.path = "/"; + request.host = (char *)GRPC_COMPUTE_ENGINE_DETECTION_HOST; + request.http.path = (char *)"/"; grpc_httpcli_context_init(&context); diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.h b/src/core/lib/security/credentials/google_default/google_default_credentials.h index c3755e01a6..66677873ca 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.h +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.h @@ -23,6 +23,10 @@ #include "src/core/lib/security/credentials/credentials.h" +#ifdef __cplusplus +extern "C" { +#endif + #define GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY "gcloud" #define GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE \ "application_default_credentials.json" @@ -41,5 +45,9 @@ void grpc_flush_cached_google_default_credentials(void); +#ifdef __cplusplus +} +#endif + #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H \ */ diff --git a/src/core/lib/security/credentials/iam/iam_credentials.c b/src/core/lib/security/credentials/iam/iam_credentials.cc index 3de8319d98..e9cf208c16 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.c +++ b/src/core/lib/security/credentials/iam/iam_credentials.cc @@ -64,7 +64,8 @@ grpc_call_credentials *grpc_google_iam_credentials_create( GPR_ASSERT(reserved == NULL); GPR_ASSERT(token != NULL); GPR_ASSERT(authority_selector != NULL); - grpc_google_iam_credentials *c = 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.vtable = &iam_vtable; gpr_ref_init(&c->base.refcount, 1); diff --git a/src/core/lib/security/credentials/jwt/json_token.c b/src/core/lib/security/credentials/jwt/json_token.cc index fff71255a5..8c30353470 100644 --- a/src/core/lib/security/credentials/jwt/json_token.c +++ b/src/core/lib/security/credentials/jwt/json_token.cc @@ -20,6 +20,7 @@ #include <string.h> +#include <grpc/grpc_security.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> @@ -29,9 +30,11 @@ #include "src/core/lib/slice/b64.h" #include "src/core/lib/support/string.h" +extern "C" { #include <openssl/bio.h> #include <openssl/evp.h> #include <openssl/pem.h> +} /* --- Constants. --- */ @@ -96,7 +99,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."); 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) { gpr_log(GPR_ERROR, "Could not deserialize private key."); goto end; @@ -214,7 +217,7 @@ static char *dot_concat_and_free_strings(char *str1, char *str2) { size_t str1_len = strlen(str1); size_t str2_len = strlen(str2); size_t result_len = str1_len + 1 /* dot */ + str2_len; - char *result = gpr_malloc(result_len + 1 /* NULL terminated */); + char *result = (char *)gpr_malloc(result_len + 1 /* NULL terminated */); char *current = result; memcpy(current, str1, str1_len); current += str1_len; @@ -266,7 +269,7 @@ char *compute_and_encode_signature(const grpc_auth_json_key *json_key, gpr_log(GPR_ERROR, "DigestFinal (get signature length) failed."); goto end; } - sig = gpr_malloc(sig_len); + sig = (unsigned char *)gpr_malloc(sig_len); if (EVP_DigestSignFinal(md_ctx, sig, &sig_len) != 1) { gpr_log(GPR_ERROR, "DigestFinal (signature compute) failed."); goto end; diff --git a/src/core/lib/security/credentials/jwt/json_token.h b/src/core/lib/security/credentials/jwt/json_token.h index e50790ef2e..b923b02df6 100644 --- a/src/core/lib/security/credentials/jwt/json_token.h +++ b/src/core/lib/security/credentials/jwt/json_token.h @@ -19,6 +19,10 @@ #ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H #define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H +#ifdef __cplusplus +extern "C" { +#endif + #include <grpc/slice.h> #include <openssl/rsa.h> @@ -70,4 +74,8 @@ typedef char *(*grpc_jwt_encode_and_sign_override)( void grpc_jwt_encode_and_sign_set_override( grpc_jwt_encode_and_sign_override func); +#ifdef __cplusplus +} +#endif + #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H */ diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.c b/src/core/lib/security/credentials/jwt/jwt_credentials.cc index 02c82e99ba..835dd677ed 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.c +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc @@ -16,8 +16,11 @@ * */ +#include <grpc/support/port_platform.h> + #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" +#include <inttypes.h> #include <string.h> #include "src/core/lib/surface/api_trace.h" @@ -125,7 +128,8 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key( gpr_log(GPR_ERROR, "Invalid input for jwt credentials creation"); return NULL; } - c = 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; gpr_ref_init(&c->base.refcount, 1); c->base.vtable = &jwt_vtable; diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h index 07f4022669..c09485fd55 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.h +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h @@ -22,6 +22,10 @@ #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/jwt/json_token.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { grpc_call_credentials base; @@ -45,4 +49,8 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key( grpc_exec_ctx *exec_ctx, grpc_auth_json_key key, gpr_timespec token_lifetime); -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */ +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */
\ No newline at end of file diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.c b/src/core/lib/security/credentials/jwt/jwt_verifier.cc index 7c24af86e8..39e72c195b 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.c +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc @@ -26,7 +26,10 @@ #include <grpc/support/string_util.h> #include <grpc/support/sync.h> #include <grpc/support/useful.h> + +extern "C" { #include <openssl/pem.h> +} #include "src/core/lib/http/httpcli.h" #include "src/core/lib/iomgr/polling_entity.h" @@ -129,7 +132,7 @@ static void jose_header_destroy(grpc_exec_ctx *exec_ctx, jose_header *h) { static jose_header *jose_header_from_json(grpc_exec_ctx *exec_ctx, grpc_json *json, grpc_slice buffer) { grpc_json *cur; - jose_header *h = gpr_zalloc(sizeof(jose_header)); + jose_header *h = (jose_header *)gpr_zalloc(sizeof(jose_header)); h->buffer = buffer; for (cur = json->child; cur != NULL; cur = cur->next) { if (strcmp(cur->key, "alg") == 0) { @@ -231,7 +234,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_json *json, grpc_slice buffer) { grpc_json *cur; - grpc_jwt_claims *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)); claims->json = json; claims->buffer = buffer; @@ -347,7 +351,7 @@ static verifier_cb_ctx *verifier_cb_ctx_create( const char *signed_jwt, size_t signed_jwt_len, void *user_data, grpc_jwt_verification_done_cb cb) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - verifier_cb_ctx *ctx = gpr_zalloc(sizeof(verifier_cb_ctx)); + verifier_cb_ctx *ctx = (verifier_cb_ctx *)gpr_zalloc(sizeof(verifier_cb_ctx)); ctx->verifier = verifier; ctx->pollent = grpc_polling_entity_create_from_pollset(pollset); ctx->header = header; @@ -676,6 +680,7 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data, grpc_json *json = json_from_http(response); grpc_httpcli_request req; const char *jwks_uri; + grpc_resource_quota *resource_quota = NULL; /* TODO(jboeuf): Cache the jwks_uri in order to avoid this hop next time. */ if (json == NULL) goto error; @@ -693,9 +698,9 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data, jwks_uri += 8; req.handshaker = &grpc_httpcli_ssl; req.host = gpr_strdup(jwks_uri); - req.http.path = strchr(jwks_uri, '/'); + req.http.path = (char *)strchr(jwks_uri, '/'); if (req.http.path == NULL) { - req.http.path = ""; + req.http.path = (char *)""; } else { *(req.host + (req.http.path - jwks_uri)) = '\0'; } @@ -703,8 +708,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 channel. This would allow us to cancel an authentication query when under extreme memory pressure. */ - grpc_resource_quota *resource_quota = - grpc_resource_quota_create("jwt_verifier"); + resource_quota = grpc_resource_quota_create("jwt_verifier"); grpc_httpcli_get( exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req, grpc_exec_ctx_now(exec_ctx) + grpc_jwt_verifier_max_delay, @@ -760,7 +764,8 @@ const char *grpc_jwt_issuer_email_domain(const char *issuer) { if (dot == NULL || dot == email_domain) return email_domain; GPR_ASSERT(dot > email_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; return dot + 1; } @@ -773,6 +778,7 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx, char *path_prefix = NULL; const char *iss; grpc_httpcli_request req; + grpc_resource_quota *resource_quota = NULL; memset(&req, 0, sizeof(grpc_httpcli_request)); req.handshaker = &grpc_httpcli_ssl; http_response_index rsp_idx; @@ -831,8 +837,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 channel. This would allow us to cancel an authentication query when under extreme memory pressure. */ - grpc_resource_quota *resource_quota = - grpc_resource_quota_create("jwt_verifier"); + resource_quota = grpc_resource_quota_create("jwt_verifier"); grpc_httpcli_get(exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req, grpc_exec_ctx_now(exec_ctx) + grpc_jwt_verifier_max_delay, @@ -901,12 +906,14 @@ error: grpc_jwt_verifier *grpc_jwt_verifier_create( const grpc_jwt_verifier_email_domain_key_url_mapping *mappings, size_t num_mappings) { - grpc_jwt_verifier *v = 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); /* We know at least of one mapping. */ v->allocated_mappings = 1 + num_mappings; - v->mappings = 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, GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX); /* User-Provided mappings. */ diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.h b/src/core/lib/security/credentials/jwt/jwt_verifier.h index 3a3261a780..998365e75c 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.h +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.h @@ -32,6 +32,10 @@ #define GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX \ "www.googleapis.com/robot/v1/metadata/x509" +#ifdef __cplusplus +extern "C" { +#endif + /* --- grpc_jwt_verifier_status. --- */ typedef enum { @@ -122,4 +126,8 @@ grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims *claims, const char *audience); const char *grpc_jwt_issuer_email_domain(const char *issuer); +#ifdef __cplusplus +} +#endif + #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H */ diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.c b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 5fe1f71f47..f52a424e36 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -130,7 +130,7 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( } if (response->body_length > 0) { - null_terminated_body = gpr_malloc(response->body_length + 1); + null_terminated_body = (char *)gpr_malloc(response->body_length + 1); null_terminated_body[response->body_length] = '\0'; memcpy(null_terminated_body, response->body, response->body_length); } @@ -354,11 +354,11 @@ static void compute_engine_fetch_oauth2( grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req, grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent, grpc_iomgr_cb_func response_cb, grpc_millis deadline) { - grpc_http_header header = {"Metadata-Flavor", "Google"}; + grpc_http_header header = {(char *)"Metadata-Flavor", (char *)"Google"}; grpc_httpcli_request request; memset(&request, 0, sizeof(grpc_httpcli_request)); - request.host = GRPC_COMPUTE_ENGINE_METADATA_HOST; - request.http.path = GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH; + request.host = (char *)GRPC_COMPUTE_ENGINE_METADATA_HOST; + request.http.path = (char *)GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH; request.http.hdr_count = 1; request.http.hdrs = &header; /* TODO(ctiller): Carry the resource_quota in ctx and share it with the host @@ -376,7 +376,8 @@ static void compute_engine_fetch_oauth2( grpc_call_credentials *grpc_google_compute_engine_credentials_create( void *reserved) { 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, (reserved)); GPR_ASSERT(reserved == NULL); @@ -407,16 +408,16 @@ static void refresh_token_fetch_oauth2( grpc_iomgr_cb_func response_cb, grpc_millis deadline) { grpc_google_refresh_token_credentials *c = (grpc_google_refresh_token_credentials *)metadata_req->creds; - grpc_http_header header = {"Content-Type", - "application/x-www-form-urlencoded"}; + grpc_http_header header = {(char *)"Content-Type", + (char *)"application/x-www-form-urlencoded"}; grpc_httpcli_request request; char *body = NULL; gpr_asprintf(&body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING, c->refresh_token.client_id, c->refresh_token.client_secret, c->refresh_token.refresh_token); memset(&request, 0, sizeof(grpc_httpcli_request)); - request.host = GRPC_GOOGLE_OAUTH2_SERVICE_HOST; - request.http.path = GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH; + request.host = (char *)GRPC_GOOGLE_OAUTH2_SERVICE_HOST; + request.http.path = (char *)GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH; request.http.hdr_count = 1; request.http.hdrs = &header; request.handshaker = &grpc_httpcli_ssl; @@ -442,7 +443,8 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token( gpr_log(GPR_ERROR, "Invalid input for refresh token credentials creation"); return NULL; } - c = 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); c->base.base.vtable = &refresh_token_vtable; c->refresh_token = refresh_token; @@ -510,7 +512,8 @@ static grpc_call_credentials_vtable access_token_vtable = { grpc_call_credentials *grpc_access_token_credentials_create( const char *access_token, void *reserved) { 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_access_token_credentials_create(access_token=<redacted>, " "reserved=%p)", diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 5d9f24307f..4beaec93e3 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -22,6 +22,10 @@ #include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/credentials.h" +#ifdef __cplusplus +extern "C" { +#endif + // auth_refresh_token parsing. typedef struct { const char *type; @@ -102,4 +106,8 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( grpc_exec_ctx *exec_ctx, const struct grpc_http_response *response, grpc_mdelem *token_md, grpc_millis *token_lifetime); -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */
\ No newline at end of file diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.c b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index ee20241e3f..8106a730fe 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.c +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -258,7 +258,8 @@ static grpc_call_credentials_vtable plugin_vtable = { grpc_call_credentials *grpc_metadata_credentials_create_from_plugin( grpc_metadata_credentials_plugin plugin, void *reserved) { - grpc_plugin_credentials *c = 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, (reserved)); GPR_ASSERT(reserved == NULL); diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.c b/src/core/lib/security/credentials/ssl/ssl_credentials.cc index 006db1ec76..9df69a2a3d 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.c +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc @@ -66,8 +66,8 @@ static grpc_security_status ssl_create_security_connector( if (status != GRPC_SECURITY_OK) { return status; } - grpc_arg new_arg = - grpc_channel_arg_string_create(GRPC_ARG_HTTP2_SCHEME, "https"); + grpc_arg new_arg = grpc_channel_arg_string_create( + (char *)GRPC_ARG_HTTP2_SCHEME, (char *)"https"); *new_args = grpc_channel_args_copy_and_add(args, &new_arg, 1); return status; } @@ -94,7 +94,8 @@ static void ssl_build_config(const char *pem_root_certs, grpc_channel_credentials *grpc_ssl_credentials_create( const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, void *reserved) { - grpc_ssl_credentials *c = gpr_zalloc(sizeof(grpc_ssl_credentials)); + grpc_ssl_credentials *c = + (grpc_ssl_credentials *)gpr_zalloc(sizeof(grpc_ssl_credentials)); GRPC_API_TRACE( "grpc_ssl_credentials_create(pem_root_certs=%s, " "pem_key_cert_pair=%p, " @@ -145,8 +146,8 @@ static void ssl_build_server_config( } if (num_key_cert_pairs > 0) { GPR_ASSERT(pem_key_cert_pairs != NULL); - config->pem_key_cert_pairs = - gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair)); + config->pem_key_cert_pairs = (tsi_ssl_pem_key_cert_pair *)gpr_zalloc( + num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair)); } config->num_key_cert_pairs = num_key_cert_pairs; 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, grpc_ssl_client_certificate_request_type client_certificate_request, void *reserved) { - grpc_ssl_server_credentials *c = - gpr_zalloc(sizeof(grpc_ssl_server_credentials)); + grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)gpr_zalloc( + sizeof(grpc_ssl_server_credentials)); GRPC_API_TRACE( "grpc_ssl_server_credentials_create_ex(" "pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, " |