Added missing return value checks following recent changes

This commit is contained in:
Alexandre Paillier
2023-10-05 15:01:58 +02:00
parent 9a9e946b50
commit 49da32af8e
14 changed files with 254 additions and 166 deletions

View File

@@ -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",