Skip to content

Commit e9d4081

Browse files
committed
auth_web3: make snprintf size_t fields portable
Replace `%lx` with `%zx`
1 parent 2a8a298 commit e9d4081

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

modules/auth_web3/web3_imple.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ int web3_oasis_get_wallet_address(const char *username, char *wallet_address) {
605605

606606
/* String length (username length in bytes) */
607607
username_len = strlen(username);
608-
ret = snprintf(call_data + pos, sizeof(call_data) - pos, "%064lx",
608+
ret = snprintf(call_data + pos, sizeof(call_data) - pos, "%064zx",
609609
username_len);
610610
if (ret < 0 || ret >= (int)(sizeof(call_data) - pos)) {
611611
LM_ERR("Failed to encode username length");
@@ -883,35 +883,35 @@ int auth_web3_check_response(dig_cred_t *cred, str *rmethod) {
883883
pos += ret;
884884

885885
/* Offset words (32 bytes each, as 64 hex chars) */
886-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", offset1);
886+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", offset1);
887887
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
888888
LM_ERR("Failed to encode offset1");
889889
goto cleanup;
890890
}
891891
pos += ret;
892892

893-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", offset2);
893+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", offset2);
894894
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
895895
LM_ERR("Failed to encode offset2");
896896
goto cleanup;
897897
}
898898
pos += ret;
899899

900-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", offset3);
900+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", offset3);
901901
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
902902
LM_ERR("Failed to encode offset3");
903903
goto cleanup;
904904
}
905905
pos += ret;
906906

907-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", offset4);
907+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", offset4);
908908
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
909909
LM_ERR("Failed to encode offset4");
910910
goto cleanup;
911911
}
912912
pos += ret;
913913

914-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", offset5);
914+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", offset5);
915915
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
916916
LM_ERR("Failed to encode offset5");
917917
goto cleanup;
@@ -927,15 +927,15 @@ int auth_web3_check_response(dig_cred_t *cred, str *rmethod) {
927927
pos += ret;
928928

929929
/* Offset for response bytes */
930-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", offset7);
930+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", offset7);
931931
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
932932
LM_ERR("Failed to encode offset7");
933933
goto cleanup;
934934
}
935935
pos += ret;
936936

937937
/* String 1: username - length + padded data */
938-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", len1);
938+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", len1);
939939
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
940940
LM_ERR("Failed to encode username length");
941941
goto cleanup;
@@ -956,7 +956,7 @@ int auth_web3_check_response(dig_cred_t *cred, str *rmethod) {
956956
}
957957

958958
/* String 2: realm - length + padded data */
959-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", len2);
959+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", len2);
960960
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
961961
LM_ERR("Failed to encode realm length");
962962
goto cleanup;
@@ -977,7 +977,7 @@ int auth_web3_check_response(dig_cred_t *cred, str *rmethod) {
977977
}
978978

979979
/* String 3: method - length + padded data */
980-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", len3);
980+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", len3);
981981
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
982982
LM_ERR("Failed to encode method length");
983983
goto cleanup;
@@ -998,7 +998,7 @@ int auth_web3_check_response(dig_cred_t *cred, str *rmethod) {
998998
}
999999

10001000
/* String 4: uri - length + padded data */
1001-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", len4);
1001+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", len4);
10021002
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
10031003
LM_ERR("Failed to encode uri length");
10041004
goto cleanup;
@@ -1019,7 +1019,7 @@ int auth_web3_check_response(dig_cred_t *cred, str *rmethod) {
10191019
}
10201020

10211021
/* String 5: nonce - length + padded data */
1022-
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064lx", len5);
1022+
ret = snprintf(call_data + pos, total_len * 2 + 1 - pos, "%064zx", len5);
10231023
if (ret < 0 || ret >= (total_len * 2 + 1 - pos)) {
10241024
LM_ERR("Failed to encode nonce length");
10251025
goto cleanup;

0 commit comments

Comments
 (0)