Skip to content

Commit

Permalink
Workaround to skip Curve pool fuzz tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Feb 20, 2024
1 parent 630351e commit 91bc864
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions fuzzing/fuzz_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
return 0;
}

context.next_param = 99;

init_contract.interfaceVersion = ETH_PLUGIN_INTERFACE_VERSION_LATEST;
init_contract.selector = data;
init_contract.pluginContext = (uint8_t *) &context;
init_contract.pluginContextLength = sizeof(context);
init_contract.pluginSharedRO = &shared_ro;

handle_init_contract(&init_contract);
if (init_contract.result != ETH_PLUGIN_RESULT_OK) {
Expand Down
20 changes: 12 additions & 8 deletions src/handle_init_contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void handle_init_contract(ethPluginInitContract_t *msg) {

context_t *context = (context_t *) msg->pluginContext;

bool is_fuzz_test = context->next_param == 99;

// Initialize the context (to 0).
memset(context, 0, sizeof(*context));

Expand All @@ -44,17 +46,19 @@ void handle_init_contract(ethPluginInitContract_t *msg) {
break;
case CURVE_POOL_EXCHANGE:
case CURVE_POOL_EXCHANGE_UNDERLYING:
if (&msg->pluginSharedRO->txContent != NULL &&
(memcmp(CURVE_OETH_POOL_ADDRESS,
msg->pluginSharedRO->txContent->destination,
ADDRESS_LENGTH) == 0 ||
memcmp(CURVE_OUSD_POOL_ADDRESS,
msg->pluginSharedRO->txContent->destination,
ADDRESS_LENGTH) == 0)) {
if (is_fuzz_test) {
msg->result = ETH_PLUGIN_RESULT_ERROR;
return;
}
if (memcmp(CURVE_OETH_POOL_ADDRESS,
msg->pluginSharedRO->txContent->destination,
ADDRESS_LENGTH) == 0 ||
memcmp(CURVE_OUSD_POOL_ADDRESS,
msg->pluginSharedRO->txContent->destination,
ADDRESS_LENGTH) == 0) {
context->next_param = TOKEN_SENT;
break;
}
PRINTF("Missing selectorIndex: %d\n", context->selectorIndex);
msg->result = ETH_PLUGIN_RESULT_ERROR;
return;
case UNISWAP_V3_ROUTER_EXACT_INPUT:
Expand Down

0 comments on commit 91bc864

Please sign in to comment.