Added missing return value checks following recent changes
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user