diff --git a/src/ui/bagl_display.c b/src/ui/bagl_display.c index c036c5113..2cce2ba23 100644 --- a/src/ui/bagl_display.c +++ b/src/ui/bagl_display.c @@ -17,9 +17,6 @@ #ifdef HAVE_BAGL -#pragma GCC diagnostic ignored "-Wformat-invalid-specifier" // snprintf -#pragma GCC diagnostic ignored "-Wformat-extra-args" // snprintf - #include // bool #include // memset @@ -102,7 +99,17 @@ int ui_display_address() { if (!address_from_pubkey(G_context.pk_info.raw_public_key, address, sizeof(address))) { return io_send_sw(SW_DISPLAY_ADDRESS_FAIL); } - snprintf(g_address, sizeof(g_address), "0x%.*H", sizeof(address), address); + + if (format_hex(address, + sizeof(address), + g_address + 2, // keep 2 bytes for "0x" + sizeof(g_address) - 2) == -1) { + return io_send_sw(SW_DISPLAY_ADDRESS_FAIL); + } + + // add "0x" at the beginning of address + g_address[0] = '0'; + g_address[1] = 'x'; g_validate_callback = &ui_action_validate_pubkey; @@ -157,7 +164,17 @@ int ui_display_transaction() { PRINTF("Amount: %s\n", g_amount); memset(g_address, 0, sizeof(g_address)); - snprintf(g_address, sizeof(g_address), "0x%.*H", ADDRESS_LEN, G_context.tx_info.transaction.to); + + if (format_hex(G_context.tx_info.transaction.to, + ADDRESS_LEN, + g_address + 2, // keep 2 bytes for "0x" + sizeof(g_address) - 2) == -1) { + return io_send_sw(SW_DISPLAY_ADDRESS_FAIL); + } + + // add "0x" at the beginning of address + g_address[0] = '0'; + g_address[1] = 'x'; g_validate_callback = &ui_action_validate_transaction; diff --git a/src/ui/nbgl_display_address.c b/src/ui/nbgl_display_address.c index 6ecf45ede..d6018ba42 100644 --- a/src/ui/nbgl_display_address.c +++ b/src/ui/nbgl_display_address.c @@ -17,9 +17,6 @@ #ifdef HAVE_NBGL -#pragma GCC diagnostic ignored "-Wformat-invalid-specifier" // snprintf -#pragma GCC diagnostic ignored "-Wformat-extra-args" // snprintf - #include // bool #include // memset @@ -75,7 +72,17 @@ int ui_display_address() { if (!address_from_pubkey(G_context.pk_info.raw_public_key, address, sizeof(address))) { return io_send_sw(SW_DISPLAY_ADDRESS_FAIL); } - snprintf(g_address, sizeof(g_address), "0x%.*H", sizeof(address), address); + + if (format_hex(address, + sizeof(address), + g_address + 2, // keep 2 bytes for "0x" + sizeof(g_address) - 2) == -1) { + return io_send_sw(SW_DISPLAY_ADDRESS_FAIL); + } + + // add "0x" at the beginning of address + g_address[0] = '0'; + g_address[1] = 'x'; nbgl_useCaseReviewStart(&C_app_boilerplate_64px, "Verify BOL address", diff --git a/src/ui/nbgl_display_transaction.c b/src/ui/nbgl_display_transaction.c index a6e2a4745..5c875b7f3 100755 --- a/src/ui/nbgl_display_transaction.c +++ b/src/ui/nbgl_display_transaction.c @@ -17,9 +17,6 @@ #ifdef HAVE_NBGL -#pragma GCC diagnostic ignored "-Wformat-invalid-specifier" // snprintf -#pragma GCC diagnostic ignored "-Wformat-extra-args" // snprintf - #include // bool #include // memset @@ -116,7 +113,17 @@ int ui_display_transaction() { } snprintf(g_amount, sizeof(g_amount), "BOL %.*s", sizeof(amount), amount); memset(g_address, 0, sizeof(g_address)); - snprintf(g_address, sizeof(g_address), "0x%.*H", ADDRESS_LEN, G_context.tx_info.transaction.to); + + if (format_hex(G_context.tx_info.transaction.to, + ADDRESS_LEN, + g_address + 2, // keep 2 bytes for "0x" + sizeof(g_address) - 2) == -1) { + return io_send_sw(SW_DISPLAY_ADDRESS_FAIL); + } + + // add "0x" at the beginning of address + g_address[0] = '0'; + g_address[1] = 'x'; // Start review nbgl_useCaseReviewStart(&C_app_boilerplate_64px,