Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions src/plugins/erc1155/erc1155_provide_parameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,19 @@ static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_cont
context->next_param = TOKEN_IDS_LENGTH;
break;
case TOKEN_IDS_LENGTH:
if ((msg->parameterOffset + PARAMETER_LENGTH) > context->ids_offset) {
context->ids_array_len =
U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->ids_array_len));
context->next_param = TOKEN_ID;
// set to zero for next step
context->array_index = 0;
if (msg->parameterOffset < context->ids_offset) {
// not there yet
break;
}
if (msg->parameterOffset != context->ids_offset) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
break;
}
context->ids_array_len =
U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->ids_array_len));
context->next_param = TOKEN_ID;
// set to zero for next step
context->array_index = 0;
break;
case TOKEN_ID:
// don't copy anything since we won't display it
Expand All @@ -69,17 +75,25 @@ static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_cont
context->array_index++;
break;
case VALUE_LENGTH:
if ((msg->parameterOffset + PARAMETER_LENGTH) > context->values_offset) {
context->values_array_len =
U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->values_array_len));
if (context->values_array_len != context->array_index) {
PRINTF("Token ids and values array sizes mismatch!");
}
context->next_param = VALUE;
// set to zero for next step
context->array_index = 0;
explicit_bzero(&context->value, sizeof(context->value));
if (msg->parameterOffset < context->values_offset) {
// not there yet
break;
}
if (msg->parameterOffset != context->values_offset) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
break;
}
context->values_array_len =
U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->values_array_len));
if (context->values_array_len != context->array_index) {
PRINTF("Token ids and values array sizes mismatch!");
msg->result = ETH_PLUGIN_RESULT_ERROR;
break;
}
context->next_param = VALUE;
// set to zero for next step
context->array_index = 0;
explicit_bzero(&context->value, sizeof(context->value));
break;
case VALUE:
// put it temporarily in token id since we don't use it in batch transfer
Expand Down
Loading