From 7508d8c61e7447c85b510cfb8e476e1c294c0b40 Mon Sep 17 00:00:00 2001 From: n4l5u0r <59141606+n4l5u0r@users.noreply.github.com> Date: Sat, 30 Nov 2024 01:52:58 +0100 Subject: [PATCH] fix: adjusted fuzzing mocks --- fuzzing/CMakeLists.txt | 6 +++++- fuzzing/mocks.c | 7 +++++++ fuzzing/mocks.h | 9 +++++++++ src/handle_init_contract.c | 1 - 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 fuzzing/mocks.h diff --git a/fuzzing/CMakeLists.txt b/fuzzing/CMakeLists.txt index 652cb8f..74b53f5 100644 --- a/fuzzing/CMakeLists.txt +++ b/fuzzing/CMakeLists.txt @@ -114,4 +114,8 @@ add_executable(fuzz ) target_compile_options(fuzz PUBLIC ${COMPILATION_FLAGS}) -target_link_options(fuzz PUBLIC ${COMPILATION_FLAGS}) \ No newline at end of file +target_link_options(fuzz PUBLIC ${COMPILATION_FLAGS}) + +if (CMAKE_C_COMPILER_ID MATCHES "Clang") + add_compile_options(-gdwarf-4) +endif() \ No newline at end of file diff --git a/fuzzing/mocks.c b/fuzzing/mocks.c index 920f196..b8d93e8 100644 --- a/fuzzing/mocks.c +++ b/fuzzing/mocks.c @@ -1,6 +1,7 @@ #include "paraswap_plugin.h" #include "lcx_common.h" #include "lcx_hash.h" +#include "mocks.h" #include size_t strlcat(char *dst, const char *src, size_t size) { @@ -45,4 +46,10 @@ cx_err_t cx_keccak_256_hash_iovec(const cx_iovec_t *iovec, void os_sched_exit(bolos_task_status_t exit_code) { return; +} + +// Mock implementation of pic function for fuzzing +void *pic(void *addr) { + // In fuzzing environment, just return the address directly + return addr; } \ No newline at end of file diff --git a/fuzzing/mocks.h b/fuzzing/mocks.h new file mode 100644 index 0000000..9ec57ce --- /dev/null +++ b/fuzzing/mocks.h @@ -0,0 +1,9 @@ +#ifndef _MOCKS_H_ +#define _MOCKS_H_ + +// Add other existing mock declarations... + +// Declaration for pic function +void *pic(void *addr); + +#endif // _MOCKS_H_ diff --git a/src/handle_init_contract.c b/src/handle_init_contract.c index a72ec67..e58e731 100644 --- a/src/handle_init_contract.c +++ b/src/handle_init_contract.c @@ -1,5 +1,4 @@ #include "paraswap_plugin.h" -#include "os_pic.h" // Called once to init. void handle_init_contract(ethPluginInitContract_t *parameters) {