aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/security
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-01-23 13:02:30 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-01-23 13:02:30 -0800
commit78d241cb3a5c367956a55a2409d5f9dedc86555c (patch)
treece9b55a6cf70748571de55044fdd93d8a7a80a02 /src/core/security
parentb1979c73af1f9eb14b3e4c5137768620118f05f8 (diff)
Remove uses of sprintf
Diffstat (limited to 'src/core/security')
-rw-r--r--src/core/security/credentials.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c
index db73c01c1d..b5ff42b337 100644
--- a/src/core/security/credentials.c
+++ b/src/core/security/credentials.c
@@ -157,7 +157,7 @@ static void ssl_server_destroy(grpc_server_credentials *creds) {
if (c->config.pem_private_keys[i] != NULL) {
gpr_free(c->config.pem_private_keys[i]);
}
- if (c->config.pem_cert_chains[i]!= NULL) {
+ if (c->config.pem_cert_chains[i] != NULL) {
gpr_free(c->config.pem_cert_chains[i]);
}
}
@@ -354,7 +354,6 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
cJSON *access_token = NULL;
cJSON *token_type = NULL;
cJSON *expires_in = NULL;
- size_t new_access_token_size = 0;
json = cJSON_Parse(null_terminated_body);
if (json == NULL) {
gpr_log(GPR_ERROR, "Could not parse JSON from %s", null_terminated_body);
@@ -384,12 +383,8 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
status = GRPC_CREDENTIALS_ERROR;
goto end;
}
- new_access_token_size = strlen(token_type->valuestring) + 1 +
- strlen(access_token->valuestring) + 1;
- new_access_token = gpr_malloc(new_access_token_size);
- /* C89 does not have snprintf :(. */
- sprintf(new_access_token, "%s %s", token_type->valuestring,
- access_token->valuestring);
+ gpr_asprintf(&new_access_token, "%s %s", token_type->valuestring,
+ access_token->valuestring);
token_lifetime->tv_sec = expires_in->valueint;
token_lifetime->tv_nsec = 0;
if (*token_elem != NULL) grpc_mdelem_unref(*token_elem);