Skip to content

Commit

Permalink
Ensure correct type for uri prints
Browse files Browse the repository at this point in the history
  • Loading branch information
tilkinsc committed Dec 5, 2023
1 parent 7107447 commit ff21a94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ COTPRESULT otp_generate(OTPData* data, uint64_t input, char* out_str)
static const uint64_t POWERS[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
code %= (uint64_t) POWERS[data->digits];

sprintf(out_str, "%0*zu", data->digits, code);
sprintf(out_str, "%0*" PRIu64, data->digits, code);

return OTP_OK;
}
Expand Down
7 changes: 4 additions & 3 deletions otpuri.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stdio.h>
#include <string.h>
#include <inttypes.h>


/*
Expand Down Expand Up @@ -131,7 +132,7 @@ COTPRESULT otpuri_build_uri(OTPData* data, const char* issuer, const char* name,
strcat(output, "&digits=");
char cdigits[21];
memset(cdigits, 0, 21);
snprintf(cdigits, 21, "%Iu", data->digits);
snprintf(cdigits, 21, "%" PRIu32, data->digits);
strcat(output, cdigits);

switch(data->method)
Expand All @@ -140,14 +141,14 @@ COTPRESULT otpuri_build_uri(OTPData* data, const char* issuer, const char* name,
strcat(output, "&period=");
char cperiod[21];
memset(cperiod, 0, 21);
snprintf(cperiod, 21, "%Iu", data->interval);
snprintf(cperiod, 21, "%" PRIu32, data->interval);
strcat(output, cperiod);
break;
case HOTP:
strcat(output, "&counter=");
char ccounter[21];
memset(ccounter, 0, 21);
snprintf(ccounter, 21, "%zu", data->count);
snprintf(ccounter, 21, "%" PRIu64, data->count);
strcat(output, ccounter);
break;
default:
Expand Down

0 comments on commit ff21a94

Please sign in to comment.