diff --git a/src/handle_check_address.c b/src/handle_check_address.c index 7950f7e..ef6d5ed 100644 --- a/src/handle_check_address.c +++ b/src/handle_check_address.c @@ -53,10 +53,12 @@ int handle_check_address(check_address_parameters_t* params, chain_config_t* cha ZERO(locals_union2); cx_ecfp_generate_pair(CX_CURVE_256K1, &locals_union2.publicKey, &locals_union1.privateKey, 1); ZERO(locals_union1); - getEthAddressStringFromKey(&locals_union2.publicKey, - locals_union1.address, - &local_sha3, - chain_config->chainId); + if (!getEthAddressStringFromKey(&locals_union2.publicKey, + locals_union1.address, + &local_sha3, + chain_config->chainId)) { + THROW(CX_INVALID_PARAMETER); + } ZERO(locals_union2); uint8_t offset_0x = 0; diff --git a/src/handle_get_printable_amount.c b/src/handle_get_printable_amount.c index 715c85d..a890ff5 100644 --- a/src/handle_get_printable_amount.c +++ b/src/handle_get_printable_amount.c @@ -33,11 +33,13 @@ int handle_get_printable_amount(get_printable_amount_parameters_t* params, chain } } - amountToString(params->amount, - params->amount_length, - decimals, - ticker, - params->printable_amount, - sizeof(params->printable_amount)); + if (!amountToString(params->amount, + params->amount_length, + decimals, + ticker, + params->printable_amount, + sizeof(params->printable_amount))) { + THROW(EXCEPTION_OVERFLOW); + } return 1; } diff --git a/src/handle_swap_sign_transaction.c b/src/handle_swap_sign_transaction.c index 604b8a2..789cbdd 100644 --- a/src/handle_swap_sign_transaction.c +++ b/src/handle_swap_sign_transaction.c @@ -35,22 +35,26 @@ bool copy_transaction_parameters(create_transaction_parameters_t* sign_transacti PRINTF("Error while parsing config\n"); return false; } - amountToString(sign_transaction_params->amount, - sign_transaction_params->amount_length, - decimals, - ticker, - stack_data.fullAmount, - sizeof(stack_data.fullAmount)); + if (!amountToString(sign_transaction_params->amount, + sign_transaction_params->amount_length, + decimals, + ticker, + stack_data.fullAmount, + sizeof(stack_data.fullAmount))) { + THROW(EXCEPTION_OVERFLOW); + } // If the amount is a fee, its value is nominated in ETH even if we're doing an ERC20 swap strlcpy(ticker, config->coinName, MAX_TICKER_LEN); decimals = WEI_TO_ETHER; - amountToString(sign_transaction_params->fee_amount, - sign_transaction_params->fee_amount_length, - decimals, - ticker, - stack_data.maxFee, - sizeof(stack_data.maxFee)); + if (!amountToString(sign_transaction_params->fee_amount, + sign_transaction_params->fee_amount_length, + decimals, + ticker, + stack_data.maxFee, + sizeof(stack_data.maxFee))) { + THROW(EXCEPTION_OVERFLOW); + } // Full reset the global variables os_explicit_zero_BSS_segment(); diff --git a/src_bagl/ui_flow_stark_sign.c b/src_bagl/ui_flow_stark_sign.c index 548e880..03174c7 100644 --- a/src_bagl/ui_flow_stark_sign.c +++ b/src_bagl/ui_flow_stark_sign.c @@ -4,6 +4,7 @@ #include "ui_callbacks.h" #include "ethUtils.h" #include "starkDisplayUtils.h" +#include "apdu_constants.h" // clang-format off UX_STEP_NOCB(ux_stark_limit_order_1_step, @@ -78,6 +79,16 @@ UX_FLOW(ux_stark_limit_order_flow, &ux_stark_limit_order_7_step, &ux_stark_limit_order_8_step); +static void stark_format_address(void) { + if (!getEthDisplayableAddress(dataContext.starkContext.conditionAddress, + strings.tmp.tmp, + sizeof(strings.tmp.tmp), + &global_sha3, + chainConfig->chainId)) { + THROW(APDU_RESPONSE_ERROR_NO_INFO); + } +} + ////////////////////////////////////////////////////////////////////// // clang-format off UX_STEP_NOCB(ux_stark_transfer_1_step, @@ -167,11 +178,7 @@ UX_STEP_NOCB_INIT( UX_STEP_NOCB_INIT( ux_stark_conditional_transfer_8_step, bnnn_paging, - getEthDisplayableAddress(dataContext.starkContext.conditionAddress, - strings.tmp.tmp, - sizeof(strings.tmp.tmp), - &global_sha3, - chainConfig->chainId), + stark_format_address(), { .title = "Cond. Address", .text = strings.tmp.tmp diff --git a/src_features/getPublicKey/cmd_getPublicKey.c b/src_features/getPublicKey/cmd_getPublicKey.c index bca0a88..eae16d5 100644 --- a/src_features/getPublicKey/cmd_getPublicKey.c +++ b/src_features/getPublicKey/cmd_getPublicKey.c @@ -49,10 +49,12 @@ void handleGetPublicKey(uint8_t p1, explicit_bzero(&privateKey, sizeof(privateKey)); explicit_bzero(privateKeyData, sizeof(privateKeyData)); io_seproxyhal_io_heartbeat(); - getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey, - tmpCtx.publicKeyContext.address, - &global_sha3, - chainConfig->chainId); + if (!getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey, + tmpCtx.publicKeyContext.address, + &global_sha3, + chainConfig->chainId)) { + THROW(CX_INVALID_PARAMETER); + } uint64_t chain_id = chainConfig->chainId; if (dataLength >= sizeof(chain_id)) { diff --git a/src_features/performPrivacyOperation/cmd_performPrivacyOperation.c b/src_features/performPrivacyOperation/cmd_performPrivacyOperation.c index 5cb9552..aebb987 100644 --- a/src_features/performPrivacyOperation/cmd_performPrivacyOperation.c +++ b/src_features/performPrivacyOperation/cmd_performPrivacyOperation.c @@ -62,10 +62,12 @@ void handlePerformPrivacyOperation(uint8_t p1, (tmpCtx.publicKeyContext.getChaincode ? tmpCtx.publicKeyContext.chainCode : NULL)); cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); cx_ecfp_generate_pair(CX_CURVE_256K1, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1); - getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey, - tmpCtx.publicKeyContext.address, - &global_sha3, - chainConfig->chainId); + if (!getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey, + tmpCtx.publicKeyContext.address, + &global_sha3, + chainConfig->chainId)) { + THROW(CX_INVALID_PARAMETER); + } if (p2 == P2_PUBLIC_ENCRYPTION_KEY) { decodeScalar(privateKeyData, privateKeyDataSwapped); cx_ecfp_init_private_key(CX_CURVE_Curve25519, privateKeyDataSwapped, 32, &privateKey); diff --git a/src_features/signMessageEIP712/ui_logic.c b/src_features/signMessageEIP712/ui_logic.c index e6f7b6a..aa7dcd8 100644 --- a/src_features/signMessageEIP712/ui_logic.c +++ b/src_features/signMessageEIP712/ui_logic.c @@ -198,11 +198,13 @@ static bool ui_712_format_addr(const uint8_t *const data, uint8_t length) { return false; } if (ui_712_field_shown()) { - getEthDisplayableAddress((uint8_t *) data, - strings.tmp.tmp, - sizeof(strings.tmp.tmp), - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress((uint8_t *) data, + strings.tmp.tmp, + sizeof(strings.tmp.tmp), + &global_sha3, + chainConfig->chainId)) { + THROW(APDU_RESPONSE_ERROR_NO_INFO); + } } return true; } diff --git a/src_features/signTx/logic_signTx.c b/src_features/signTx/logic_signTx.c index c84e9d1..5c47e64 100644 --- a/src_features/signTx/logic_signTx.c +++ b/src_features/signTx/logic_signTx.c @@ -1,3 +1,4 @@ +#include #include "shared_context.h" #include "utils.h" #include "feature_signTx.h" @@ -9,7 +10,7 @@ #include "ethUtils.h" #include "common_ui.h" #include "ui_callbacks.h" -#include +#include "apdu_constants.h" #define ERR_SILENT_MODE_CHECK_FAILED 0x6001 @@ -189,7 +190,9 @@ static void address_to_string(uint8_t *in, cx_sha3_t *sha3, uint64_t chainId) { if (in_len != 0) { - getEthDisplayableAddress(in, out, out_len, sha3, chainId); + if (!getEthDisplayableAddress(in, out, out_len, sha3, chainId)) { + THROW(APDU_RESPONSE_ERROR_NO_INFO); + } } else { strlcpy(out, "Contract", out_len); } @@ -269,7 +272,9 @@ static void get_network_as_string(char *out, size_t out_size) { if (name == NULL) { // No network name found so simply copy the chain ID as the network name. - u64_to_string(chain_id, out, out_size); + if (!u64_to_string(chain_id, out, out_size)) { + THROW(0x6502); + } } else { // Network name found, simply copy it. strlcpy(out, name, out_size); @@ -294,7 +299,9 @@ static void get_public_key(uint8_t *out, uint8_t outLength) { cx_ecfp_generate_pair(CX_CURVE_256K1, &publicKey, &privateKey, 1); explicit_bzero(&privateKey, sizeof(privateKey)); explicit_bzero(privateKeyData, sizeof(privateKeyData)); - getEthAddressFromKey(&publicKey, out, &global_sha3); + if (!getEthAddressFromKey(&publicKey, out, &global_sha3)) { + THROW(CX_INVALID_PARAMETER); + } } /* Local implmentation of strncasecmp, workaround of the segfaulting base implem diff --git a/src_nbgl/ui_stark_transfer.c b/src_nbgl/ui_stark_transfer.c index d7decfb..bb41e1e 100644 --- a/src_nbgl/ui_stark_transfer.c +++ b/src_nbgl/ui_stark_transfer.c @@ -65,11 +65,13 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { } if (page == 1) { if (context.conditional) { - getEthDisplayableAddress(dataContext.starkContext.conditionAddress, - condAddressBuffer, - sizeof(condAddressBuffer), - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(dataContext.starkContext.conditionAddress, + condAddressBuffer, + sizeof(condAddressBuffer), + &global_sha3, + chainConfig->chainId)) { + return false; + } pairs[0].item = "Cond. Address"; pairs[0].value = condAddressBuffer; diff --git a/src_plugins/erc1155/erc1155_ui.c b/src_plugins/erc1155/erc1155_ui.c index 4306704..72ea223 100644 --- a/src_plugins/erc1155/erc1155_ui.c +++ b/src_plugins/erc1155/erc1155_ui.c @@ -14,11 +14,13 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc1155_context_t } else { strlcpy(msg->title, "Revoke", msg->titleLength); } - getEthDisplayableAddress(context->address, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->address, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 1: strlcpy(msg->title, "To Manage ALL", msg->titleLength); @@ -26,11 +28,13 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc1155_context_t break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(msg->item1->nft.contractAddress, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(msg->item1->nft.contractAddress, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; default: PRINTF("Unsupported screen index %d\n", msg->screenIndex); @@ -43,11 +47,13 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex switch (msg->screenIndex) { case 0: strlcpy(msg->title, "To", msg->titleLength); - getEthDisplayableAddress(context->address, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->address, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 1: strlcpy(msg->title, "Collection Name", msg->titleLength); @@ -55,22 +61,28 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(msg->item1->nft.contractAddress, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(msg->item1->nft.contractAddress, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 3: strlcpy(msg->title, "NFT ID", msg->titleLength); - uint256_to_decimal(context->tokenId, - sizeof(context->tokenId), - msg->msg, - msg->msgLength); + if (!uint256_to_decimal(context->tokenId, + sizeof(context->tokenId), + msg->msg, + msg->msgLength)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 4: strlcpy(msg->title, "Quantity", msg->titleLength); - tostring256(&context->value, 10, msg->msg, msg->msgLength); + if (!tostring256(&context->value, 10, msg->msg, msg->msgLength)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; default: PRINTF("Unsupported screen index %d\n", msg->screenIndex); @@ -85,11 +97,13 @@ static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t * switch (msg->screenIndex) { case 0: strlcpy(msg->title, "To", msg->titleLength); - getEthDisplayableAddress(context->address, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->address, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 1: strlcpy(msg->title, "Collection Name", msg->titleLength); @@ -97,15 +111,20 @@ static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t * break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(msg->item1->nft.contractAddress, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(msg->item1->nft.contractAddress, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 3: strlcpy(msg->title, "Total Quantity", msg->titleLength); - tostring256(&context->value, 10, &quantity_str[0], sizeof(quantity_str)); + if (!tostring256(&context->value, 10, &quantity_str[0], sizeof(quantity_str))) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + break; + } snprintf(msg->msg, msg->msgLength, "%s from %d NFT IDs", diff --git a/src_plugins/erc20/erc20_plugin.c b/src_plugins/erc20/erc20_plugin.c index 220e05f..33380db 100644 --- a/src_plugins/erc20/erc20_plugin.c +++ b/src_plugins/erc20/erc20_plugin.c @@ -201,12 +201,14 @@ void erc20_plugin_call(int message, void *parameters) { strlcpy(msg->msg, "Unlimited ", msg->msgLength); strlcat(msg->msg, context->ticker, msg->msgLength); } else { - amountToString(context->amount, - sizeof(context->amount), - context->decimals, - context->ticker, - msg->msg, - 100); + if (!amountToString(context->amount, + sizeof(context->amount), + context->decimals, + context->ticker, + msg->msg, + 100)) { + THROW(EXCEPTION_OVERFLOW); + } } msg->result = ETH_PLUGIN_RESULT_OK; break; @@ -216,11 +218,13 @@ void erc20_plugin_call(int message, void *parameters) { strlcpy(msg->msg, context->contract_name, msg->msgLength); } else { strlcpy(msg->title, "Address", msg->titleLength); - getEthDisplayableAddress(context->destinationAddress, - msg->msg, - msg->msgLength, - msg->pluginSharedRW->sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->destinationAddress, + msg->msg, + msg->msgLength, + msg->pluginSharedRW->sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } } msg->result = ETH_PLUGIN_RESULT_OK; diff --git a/src_plugins/erc721/erc721_ui.c b/src_plugins/erc721/erc721_ui.c index 8fc4c59..caaf395 100644 --- a/src_plugins/erc721/erc721_ui.c +++ b/src_plugins/erc721/erc721_ui.c @@ -10,11 +10,13 @@ static void set_approval_ui(ethQueryContractUI_t *msg, erc721_context_t *context switch (msg->screenIndex) { case 0: strlcpy(msg->title, "Allow", msg->titleLength); - getEthDisplayableAddress(context->address, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->address, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 1: strlcpy(msg->title, "To Manage Your", msg->titleLength); @@ -22,18 +24,22 @@ static void set_approval_ui(ethQueryContractUI_t *msg, erc721_context_t *context break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(msg->item1->nft.contractAddress, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(msg->item1->nft.contractAddress, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 3: strlcpy(msg->title, "NFT ID", msg->titleLength); - uint256_to_decimal(context->tokenId, - sizeof(context->tokenId), - msg->msg, - msg->msgLength); + if (!uint256_to_decimal(context->tokenId, + sizeof(context->tokenId), + msg->msg, + msg->msgLength)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; default: PRINTF("Unsupported screen index %d\n", msg->screenIndex); @@ -50,11 +56,13 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc721_context_t } else { strlcpy(msg->title, "Revoke", msg->titleLength); } - getEthDisplayableAddress(context->address, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->address, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 1: strlcpy(msg->title, "To Manage ALL", msg->titleLength); @@ -62,11 +70,13 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc721_context_t break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(msg->item1->nft.contractAddress, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(msg->item1->nft.contractAddress, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; default: PRINTF("Unsupported screen index %d\n", msg->screenIndex); @@ -79,11 +89,13 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc721_context_t *context switch (msg->screenIndex) { case 0: strlcpy(msg->title, "To", msg->titleLength); - getEthDisplayableAddress(context->address, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->address, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 1: strlcpy(msg->title, "Collection Name", msg->titleLength); @@ -91,18 +103,22 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc721_context_t *context break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(msg->item1->nft.contractAddress, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(msg->item1->nft.contractAddress, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; case 3: strlcpy(msg->title, "NFT ID", msg->titleLength); - uint256_to_decimal(context->tokenId, - sizeof(context->tokenId), - msg->msg, - msg->msgLength); + if (!uint256_to_decimal(context->tokenId, + sizeof(context->tokenId), + msg->msg, + msg->msgLength)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + } break; default: PRINTF("Unsupported screen index %d\n", msg->screenIndex); diff --git a/src_plugins/eth2/eth2_plugin.c b/src_plugins/eth2/eth2_plugin.c index c93c82e..352a9f3 100644 --- a/src_plugins/eth2/eth2_plugin.c +++ b/src_plugins/eth2/eth2_plugin.c @@ -117,11 +117,14 @@ void eth2_plugin_call(int message, void *parameters) { // Use a temporary buffer to store the string representation. char tmp[ETH2_DEPOSIT_PUBKEY_LENGTH]; - getEthDisplayableAddress((uint8_t *) context->deposit_address, - tmp, - sizeof(tmp), - msg->pluginSharedRW->sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress((uint8_t *) context->deposit_address, + tmp, + sizeof(tmp), + msg->pluginSharedRW->sha3, + chainConfig->chainId)) { + msg->result = ETH_PLUGIN_RESULT_ERROR; + return; + } // Copy back the string to the global variable. strlcpy(context->deposit_address, tmp, ETH2_DEPOSIT_PUBKEY_LENGTH); @@ -200,12 +203,14 @@ void eth2_plugin_call(int message, void *parameters) { uint8_t decimals = WEI_TO_ETHER; char *ticker = chainConfig->coinName; strlcpy(msg->title, "Amount", msg->titleLength); - amountToString(tmpContent.txContent.value.value, - tmpContent.txContent.value.length, - decimals, - ticker, - msg->msg, - 100); + if (!amountToString(tmpContent.txContent.value.value, + tmpContent.txContent.value.length, + decimals, + ticker, + msg->msg, + 100)) { + THROW(EXCEPTION_OVERFLOW); + } msg->result = ETH_PLUGIN_RESULT_OK; } break; case 1: { // Deposit pubkey screen diff --git a/src_plugins/starkware/starkware_plugin.c b/src_plugins/starkware/starkware_plugin.c index 634ea4e..d0ee269 100644 --- a/src_plugins/starkware/starkware_plugin.c +++ b/src_plugins/starkware/starkware_plugin.c @@ -6,6 +6,7 @@ #include "stark_utils.h" #include "utils.h" #include "ethUtils.h" +#include "apdu_constants.h" #ifdef HAVE_STARKWARE @@ -352,11 +353,13 @@ void starkware_print_asset_contract(char *destination, size_t destinationLength) if (dataContext.tokenContext.quantumIndex != MAX_ITEMS) { tokenDefinition_t *token = &tmpCtx.transactionContext.extraInfo[dataContext.tokenContext.quantumIndex].token; - getEthDisplayableAddress(token->address, - destination, - destinationLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(token->address, + destination, + destinationLength, + &global_sha3, + chainConfig->chainId)) { + THROW(APDU_RESPONSE_ERROR_NO_INFO); + } } else { strlcpy(destination, "UNKNOWN", destinationLength); } @@ -380,7 +383,12 @@ void starkware_get_source_address(char *destination) { io_seproxyhal_io_heartbeat(); destination[0] = '0'; destination[1] = 'x'; - getEthAddressStringFromKey(&publicKey, destination + 2, &global_sha3, chainConfig->chainId); + if (!getEthAddressStringFromKey(&publicKey, + destination + 2, + &global_sha3, + chainConfig->chainId)) { + THROW(CX_INVALID_PARAMETER); + } destination[42] = '\0'; } @@ -716,11 +724,13 @@ void starkware_plugin_call(int message, void *parameters) { if (is_deversify_contract(tmpContent.txContent.destination)) { strlcpy(msg->msg, "DeversiFi", msg->msgLength); } else { - getEthDisplayableAddress(tmpContent.txContent.destination, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(tmpContent.txContent.destination, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + THROW(APDU_RESPONSE_ERROR_NO_INFO); + } } msg->result = ETH_PLUGIN_RESULT_OK; break; @@ -730,11 +740,13 @@ void starkware_plugin_call(int message, void *parameters) { case STARKWARE_REGISTER_AND_DEPOSIT_TOKEN: case STARKWARE_REGISTER_AND_DEPOSIT_ETH: strlcpy(msg->title, "From ETH Address", msg->titleLength); - getEthDisplayableAddress(context->amount, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->amount, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + THROW(APDU_RESPONSE_ERROR_NO_INFO); + } break; case STARKWARE_ESCAPE: strlcpy(msg->title, "Amount", msg->titleLength); @@ -806,11 +818,13 @@ void starkware_plugin_call(int message, void *parameters) { case STARKWARE_WITHDRAW_TO: case STARKWARE_WITHDRAW_NFT_TO: strlcpy(msg->title, "To ETH Address", msg->titleLength); - getEthDisplayableAddress(context->amount, - msg->msg, - msg->msgLength, - &global_sha3, - chainConfig->chainId); + if (!getEthDisplayableAddress(context->amount, + msg->msg, + msg->msgLength, + &global_sha3, + chainConfig->chainId)) { + THROW(APDU_RESPONSE_ERROR_NO_INFO); + } break; case STARKWARE_WITHDRAW_AND_MINT: strlcpy(msg->title, "Asset Contract", msg->titleLength);