Skip to content

Commit

Permalink
fix(ocv2): bad index jumps
Browse files Browse the repository at this point in the history
  • Loading branch information
loicttn committed Dec 13, 2024
1 parent 62a2a87 commit ca2170d
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions src/provide_parameter/ocv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ void handle_v2_claim(ethPluginProvideParameter_t *msg, context_t *context) {
break;
case V2_CLAIM_TICKET_IDS_LENGTH:
U2BE_from_parameter(msg->parameter, &params->current_item_count);
context->next_param = V2_CLAIM_TICKET_IDS__ITEMS;
if (params->current_item_count == 0) {
context->next_param = V2_CLAIM_CASK_IDS_LENGTH;
} else {
context->next_param = V2_CLAIM_TICKET_IDS__ITEMS;
}
break;
case V2_CLAIM_TICKET_IDS__ITEMS:
if (params->current_item_count > 0) {
Expand All @@ -114,7 +118,11 @@ void handle_v2_claim(ethPluginProvideParameter_t *msg, context_t *context) {
return;
}
U2BE_from_parameter(msg->parameter, &params->current_item_count);
context->next_param = V2_CLAIM_CASK_IDS__ITEMS;
if (params->current_item_count == 0) {
context->next_param = V2_CLAIM_UNEXPECTED_PARAMETER;
} else {
context->next_param = V2_CLAIM_CASK_IDS__ITEMS;
}
break;
case V2_CLAIM_CASK_IDS__ITEMS:
if (params->current_item_count > 0) {
Expand Down Expand Up @@ -198,7 +206,11 @@ void handle_v2_multiclaim(ethPluginProvideParameter_t *msg, context_t *context)
break;
case V2_MULTICLAIM_EXIT_QUEUES_LENGTH:
U2BE_from_parameter(msg->parameter, &params->current_item_count);
context->next_param = V2_MULTICLAIM_EXIT_QUEUES__ITEMS;
if (params->current_item_count == 0) {
context->next_param = V2_MULTICLAIM_TICKETIDS_LENGTH;
} else {
context->next_param = V2_MULTICLAIM_EXIT_QUEUES__ITEMS;
}
break;
case V2_MULTICLAIM_EXIT_QUEUES__ITEMS: {
uint8_t buffer[ADDRESS_LENGTH];
Expand Down Expand Up @@ -243,8 +255,11 @@ void handle_v2_multiclaim(ethPluginProvideParameter_t *msg, context_t *context)

U2BE_from_parameter(msg->parameter, &params->parent_item_count);
params->current_item_count = params->parent_item_count;

context->next_param = V2_MULTICLAIM_TICKETIDS__OFFSET_ITEMS;
if (params->current_item_count == 0) {
context->next_param = V2_MULTICLAIM_TICKETIDS__ITEM_LENGTH;
} else {
context->next_param = V2_MULTICLAIM_TICKETIDS__OFFSET_ITEMS;
}
break;
// ********************************************************************
// TICKETIDS[][]
Expand Down Expand Up @@ -312,7 +327,11 @@ void handle_v2_multiclaim(ethPluginProvideParameter_t *msg, context_t *context)
}

U2BE_from_parameter(msg->parameter, &params->current_item_count);
context->next_param = V2_MULTICLAIM_TICKETIDS__ITEM__ITEMS;
if (params->current_item_count == 0) {
context->next_param = V2_MULTICLAIM_CASKIDS_LENGTH;
} else {
context->next_param = V2_MULTICLAIM_TICKETIDS__ITEM__ITEMS;
}
break;
}
case V2_MULTICLAIM_TICKETIDS__ITEM__ITEMS:
Expand Down Expand Up @@ -358,7 +377,11 @@ void handle_v2_multiclaim(ethPluginProvideParameter_t *msg, context_t *context)

U2BE_from_parameter(msg->parameter, &params->parent_item_count);
params->current_item_count = params->parent_item_count;
context->next_param = V2_MULTICLAIM_CASKIDS__OFFSET_ITEMS;
if (params->current_item_count == 0) {
context->next_param = V2_MULTICLAIM_CASKIDS__ITEM_LENGTH;
} else {
context->next_param = V2_MULTICLAIM_CASKIDS__OFFSET_ITEMS;
}
break;
case V2_MULTICLAIM_CASKIDS__OFFSET_ITEMS: {
uint16_t offset;
Expand Down Expand Up @@ -424,7 +447,11 @@ void handle_v2_multiclaim(ethPluginProvideParameter_t *msg, context_t *context)
}

U2BE_from_parameter(msg->parameter, &params->current_item_count);
context->next_param = V2_MULTICLAIM_CASKIDS__ITEM__ITEMS;
if (params->current_item_count == 0) {
context->next_param = V2_MULTICLAIM_UNEXPECTED_PARAMETER;
} else {
context->next_param = V2_MULTICLAIM_CASKIDS__ITEM__ITEMS;
}
break;
}
case V2_MULTICLAIM_CASKIDS__ITEM__ITEMS:
Expand Down

0 comments on commit ca2170d

Please sign in to comment.