aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/security/credentials/jwt
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-09-20 11:28:25 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-10-02 16:22:41 -0700
commitacd46e571c3dd4721a21c934c4ccb983ed2f687c (patch)
tree5d886d730d785318317cf161db4262fb52324507 /src/core/lib/security/credentials/jwt
parent20987394e90298d410051852734afdc8cf6d2918 (diff)
More pointer conversions, deprecated string to char *, goto crossing initializations
Diffstat (limited to 'src/core/lib/security/credentials/jwt')
-rw-r--r--src/core/lib/security/credentials/jwt/json_token.c6
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.c3
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.c27
3 files changed, 20 insertions, 16 deletions
diff --git a/src/core/lib/security/credentials/jwt/json_token.c b/src/core/lib/security/credentials/jwt/json_token.c
index 4f1456c384..e41667c22f 100644
--- a/src/core/lib/security/credentials/jwt/json_token.c
+++ b/src/core/lib/security/credentials/jwt/json_token.c
@@ -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.");
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 +214,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 = (char*) 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 +266,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 = (unsigned char*) 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/jwt_credentials.c b/src/core/lib/security/credentials/jwt/jwt_credentials.c
index 58610a1b69..b361265a7b 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.c
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.c
@@ -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");
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;
gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &jwt_vtable;
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.c b/src/core/lib/security/credentials/jwt/jwt_verifier.c
index 1a8e1cf9ed..97574cfbd9 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.c
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.c
@@ -129,7 +129,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 = (jose_header*) 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 +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_json *json, grpc_slice buffer) {
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));
claims->json = json;
claims->buffer = buffer;
@@ -347,7 +348,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 = (verifier_cb_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 +677,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 +695,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 +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
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,
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;
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 +774,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 +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
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,
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(
const grpc_jwt_verifier_email_domain_key_url_mapping *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);
/* We know at least of one mapping. */
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,
GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX);
/* User-Provided mappings. */