Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix size_t and time_t format specifiers #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/stir_shaken_passport.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,13 +815,13 @@ stir_shaken_status_t stir_shaken_passport_validate_iat_against_freshness(stir_sh
}

if (now_s < iat) {
snprintf(err_buf, STIR_SHAKEN_ERROR_BUF_LEN, "PASSporT's @iat (in seconds) is: %zu, freshness is: %u, BUT now is %zu (this is PASSporT to the future, too young, not valid yet)", iat, iat_freshness, now_s);
snprintf(err_buf, STIR_SHAKEN_ERROR_BUF_LEN, "PASSporT's @iat (in seconds) is: %lld, freshness is: %u, BUT now is %lld (this is PASSporT to the future, too young, not valid yet)", (long long)iat, iat_freshness, (long long)now_s);
stir_shaken_set_error(ss, err_buf, STIR_SHAKEN_ERROR_PASSPORT_INVALID_IAT_VALUE_FUTURE);
return STIR_SHAKEN_STATUS_ERR;
}

if (iat + iat_freshness < now_s) {
snprintf(err_buf, STIR_SHAKEN_ERROR_BUF_LEN, "PASSporT's @iat (in seconds) is: %zu, freshness is: %u, BUT now is %zu (PASSporT too old, expired)", iat, iat_freshness, now_s);
snprintf(err_buf, STIR_SHAKEN_ERROR_BUF_LEN, "PASSporT's @iat (in seconds) is: %lld, freshness is: %u, BUT now is %lld (PASSporT too old, expired)", (long long)iat, iat_freshness, (long long)now_s);
stir_shaken_set_error(ss, err_buf, STIR_SHAKEN_ERROR_PASSPORT_INVALID_IAT_VALUE_EXPIRED);
return STIR_SHAKEN_STATUS_ERR;
}
Expand Down
14 changes: 7 additions & 7 deletions util/src/stir_shaken_ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static void close_http_connection_with_error(struct mg_connection *nc, struct mb
char error_phrase[STIR_SHAKEN_BUFLEN] = { 0 };
stir_shaken_error_desc_to_http_error_phrase(error_desc, error_phrase, STIR_SHAKEN_BUFLEN);
if (error_body)
mg_printf(nc, "HTTP/1.1 %s %s\r\nContent-Length: %lu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", STIR_SHAKEN_HTTP_REQ_404_NOT_FOUND, error_phrase, strlen(error_body), error_body);
mg_printf(nc, "HTTP/1.1 %s %s\r\nContent-Length: %zu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", STIR_SHAKEN_HTTP_REQ_404_NOT_FOUND, error_phrase, strlen(error_body), error_body);
else
mg_printf(nc, "HTTP/1.1 %s %s\r\n\r\n", STIR_SHAKEN_HTTP_REQ_404_NOT_FOUND, error_phrase);
}
Expand Down Expand Up @@ -533,7 +533,7 @@ static void ca_handle_api_cert(struct mg_connection *nc, int event, void *hm, vo
fprintif(STIR_SHAKEN_LOGLEVEL_MEDIUM, "\t-> Added authorization session to queue\n");
fprintif(STIR_SHAKEN_LOGLEVEL_MEDIUM, "\t-> Sending authorization challenge:\n%s\n", authz_challenge);

mg_printf(nc, "HTTP/1.1 201 Created\r\nReplay-Nonce: %s\r\nLocation: %s\r\nContent-Length: %lu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", nonce, authz_url, strlen(authz_challenge), authz_challenge);
mg_printf(nc, "HTTP/1.1 201 Created\r\nReplay-Nonce: %s\r\nLocation: %s\r\nContent-Length: %zu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", nonce, authz_url, strlen(authz_challenge), authz_challenge);

session->state = STI_CA_SESSION_STATE_AUTHZ_SENT;

Expand Down Expand Up @@ -595,7 +595,7 @@ static void ca_handle_api_cert(struct mg_connection *nc, int event, void *hm, vo
fprintif(STIR_SHAKEN_LOGLEVEL_MEDIUM, "\t\t\t-> STI-SP certificate is:\n%s\n", cert);

fprintif(STIR_SHAKEN_LOGLEVEL_MEDIUM, "\t\t-> Sending STI-SP certificate...\n");
mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", strlen((const char *)cert), cert);
mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", strlen((const char *)cert), cert);

session->state = STI_CA_SESSION_STATE_DONE;

Expand Down Expand Up @@ -897,7 +897,7 @@ static void ca_handle_api_authz(struct mg_connection *nc, int event, void *hm, v

fprintif(STIR_SHAKEN_LOGLEVEL_MEDIUM, "-> Sending polling status...\n");

mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", strlen(session->authz_polling_status), session->authz_polling_status);
mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", strlen(session->authz_polling_status), session->authz_polling_status);

// continue
session->state = STI_CA_SESSION_STATE_POLLING;
Expand Down Expand Up @@ -928,7 +928,7 @@ static void ca_handle_api_authz(struct mg_connection *nc, int event, void *hm, v

fprintif(STIR_SHAKEN_LOGLEVEL_MEDIUM, "-> Sending challenge details:\n%s\n", session->authz_challenge_details);

mg_printf(nc, "HTTP/1.1 200 You are more than welcome. Here is your challenge:\r\nContent-Length: %lu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", strlen(session->authz_challenge_details), session->authz_challenge_details);
mg_printf(nc, "HTTP/1.1 200 You are more than welcome. Here is your challenge:\r\nContent-Length: %zu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", strlen(session->authz_challenge_details), session->authz_challenge_details);

session->state = STI_CA_SESSION_STATE_AUTHZ_DETAILS_SENT;
}
Expand Down Expand Up @@ -1085,7 +1085,7 @@ static void ca_handle_api_authz(struct mg_connection *nc, int event, void *hm, v
}

fprintif(STIR_SHAKEN_LOGLEVEL_MEDIUM, "\t -> Configuring certificate...\n");
snprintf(session->sp.cert_name, sizeof(session->sp.cert_name), "sp_%s_%llu_%zu.pem", spc, secret, time(NULL));
snprintf(session->sp.cert_name, sizeof(session->sp.cert_name), "sp_%s_%llu_%lld.pem", spc, secret, (long long)time(NULL));

fprintif(STIR_SHAKEN_LOGLEVEL_MEDIUM, "\t -> Saving certificate (%s)...\n", session->sp.cert_name);
if (STIR_SHAKEN_STATUS_OK != stir_shaken_x509_to_disk(&ca->ss, session->sp.cert.x, session->sp.cert_name)) {
Expand Down Expand Up @@ -1234,7 +1234,7 @@ static void ca_handle_api_authority_check(struct mg_connection *nc, int event, v
ks_json_add_string_to_object(json, "authority", check_result);
json_str = ks_json_print_unformatted(json);

mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %lu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", strlen(json_str), json_str);
mg_printf(nc, "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\nContent-Type: application/json\r\n\r\n%s\r\n\r\n", strlen(json_str), json_str);

ks_json_delete(&json);
json = NULL;
Expand Down