diff --git a/src/oxen_ux_nano.c b/src/oxen_ux_nano.c index cba0cf5..c5bafc8 100644 --- a/src/oxen_ux_nano.c +++ b/src/oxen_ux_nano.c @@ -110,10 +110,8 @@ unsigned int ui_menu_info_action(void) { } void ui_menu_info_display2(const char* line1, const char* line2) { - memmove(G_oxen_state.ux_info1, line1, sizeof(G_oxen_state.ux_info1) - 1); - memmove(G_oxen_state.ux_info2, line2, sizeof(G_oxen_state.ux_info2) - 1); - G_oxen_state.ux_info1[sizeof(G_oxen_state.ux_info1) - 1] = 0; - G_oxen_state.ux_info2[sizeof(G_oxen_state.ux_info2) - 1] = 0; + strncpy(G_oxen_state.ux_info1, line1, sizeof(G_oxen_state.ux_info1)); + strncpy(G_oxen_state.ux_info2, line2, sizeof(G_oxen_state.ux_info2)); ux_flow_init(0, ux_flow_info, NULL); } @@ -130,8 +128,7 @@ static const char* processing_tx(void) { } void ui_menu_opentx_display(unsigned char final_step) { - memmove(G_oxen_state.ux_info1, processing_tx(), sizeof(G_oxen_state.ux_info1) - 1); - G_oxen_state.ux_info1[sizeof(G_oxen_state.ux_info1) - 1] = 0; + strncpy(G_oxen_state.ux_info1, processing_tx(), sizeof(G_oxen_state.ux_info1)); if (final_step) ux_flow_init(0, ux_flow_info_icon4, NULL); @@ -684,19 +681,19 @@ void ui_menu_any_pubaddr_display(unsigned char* pub_view, switch (G_oxen_state.disp_addr_mode) { case 0: case DISP_MAIN: - memmove(G_oxen_state.ux_addr_type, "Regular address", 15); + strncpy(G_oxen_state.ux_addr_type, "Regular address", sizeof(G_oxen_state.ux_addr_type)); if (N_oxen_state->network_id == MAINNET) - memmove(G_oxen_state.ux_addr_info, "(mainnet)", 9); + strncpy(G_oxen_state.ux_addr_info, "(mainnet)", sizeof(G_oxen_state.ux_addr_info)); else if (N_oxen_state->network_id == TESTNET) - memmove(G_oxen_state.ux_addr_info, "(testnet)", 9); + strncpy(G_oxen_state.ux_addr_info, "(testnet)", sizeof(G_oxen_state.ux_addr_info)); else if (N_oxen_state->network_id == DEVNET) - memmove(G_oxen_state.ux_addr_info, "(devnet)", 8); + strncpy(G_oxen_state.ux_addr_info, "(devnet)", sizeof(G_oxen_state.ux_addr_info)); else if (N_oxen_state->network_id == FAKECHAIN) - memmove(G_oxen_state.ux_addr_info, "(fakenet)", 9); + strncpy(G_oxen_state.ux_addr_info, "(fakenet)", sizeof(G_oxen_state.ux_addr_info)); break; case DISP_SUB: - memmove(G_oxen_state.ux_addr_type, "Subaddress", 10); + strncpy(G_oxen_state.ux_addr_type, "Subaddress", sizeof(G_oxen_state.ux_addr_type)); // Copy these out because they are in a union with the ux_addr_info string unsigned int M = G_oxen_state.disp_addr_M; unsigned int m = G_oxen_state.disp_addr_m; @@ -704,10 +701,10 @@ void ui_menu_any_pubaddr_display(unsigned char* pub_view, break; case DISP_INTEGRATED: - memmove(G_oxen_state.ux_addr_type, "Integr. address", 15); + strncpy(G_oxen_state.ux_addr_type, "Integr. address", sizeof(G_oxen_state.ux_addr_type)); // Copy the payment id into place *first*, before the label, because it overlaps with // ux_addr_info - memmove(G_oxen_state.ux_addr_info + 9, G_oxen_state.payment_id, 16); + memmove(G_oxen_state.ux_addr_info + 9, G_oxen_state.payment_id, sizeof(G_oxen_state.payment_id)); memmove(G_oxen_state.ux_addr_info, "Pay. ID: ", 9); break; }