Skip to content

Commit 41d8d78

Browse files
committed
fix: Apped zeros when converting mpz to string
1 parent 44a4e78 commit 41d8d78

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

apps/starknet_app/starknet_pub_key.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,21 @@ void starknet_get_pub_keys(starknet_query_t *query) {
517517
if (STARKNET_QUERY_GET_USER_VERIFIED_PUBLIC_KEY_TAG == which_request) {
518518
char address[100] = "0x";
519519

520-
// Calculate to-be account address
521-
starknet_derive_argent_address(&public_keys[0][0], &address[2]);
520+
{
521+
char raw_address[100] = {0};
522+
// Calculate to-be account address
523+
starknet_derive_argent_address(&public_keys[0][0], raw_address);
524+
525+
size_t len = 64 - strnlen(raw_address, sizeof(raw_address));
526+
if (len < 0) {
527+
len = 0;
528+
}
529+
uint8_t index = 2;
530+
while (len--) {
531+
sprintf(address + index++, "0");
532+
}
533+
snprintf(address + index, sizeof(address) - index, raw_address);
534+
}
522535

523536
if (!core_scroll_page(ui_text_receive_on, address, starknet_send_error)) {
524537
return;
@@ -537,4 +550,4 @@ void starknet_get_pub_keys(starknet_query_t *query) {
537550
}
538551

539552
delay_scr_init(ui_text_check_cysync_app, DELAY_TIME);
540-
}
553+
}

0 commit comments

Comments
 (0)