From: Alan T. DeKok Date: Sun, 4 Feb 2024 16:09:33 +0000 (-0500) Subject: make sure that we call library init / free X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c88c51411ce57dc1b626ce75f9e6e9f5500cbfcb;p=thirdparty%2Ffreeradius-server.git make sure that we call library init / free --- diff --git a/src/bin/fuzzer.c b/src/bin/fuzzer.c index 6ca0a4bee2d..82f7b0ff136 100644 --- a/src/bin/fuzzer.c +++ b/src/bin/fuzzer.c @@ -42,6 +42,7 @@ static bool init = false; static fr_test_point_proto_decode_t *tp = NULL; static dl_t *dl = NULL; static dl_loader_t *dl_loader; +static fr_dict_protocol_t *dl_proto; static fr_dict_t *dict = NULL; @@ -50,6 +51,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len); static void exitHandler(void) { + if (dl_proto && dl_proto->free) dl_proto->free(); + fr_dict_free(&dict, __FILE__); if (dl && dl->handle) { @@ -218,6 +221,14 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) fr_exit_now(EXIT_FAILURE); } + snprintf(buffer, sizeof(buffer), "libfreeradius_%s_dict_protocol", proto); + + dl_proto = dlsym(dl->handle, buffer); + if (dl_proto && dl_proto->init() && (dl_proto->init() < 0)) { + fr_perror("fuzzer: Failed initializing library %s", buffer); + fr_exit_now(EXIT_FAILURE); + } + snprintf(buffer, sizeof(buffer), "%s_tp_decode_proto", proto); tp = dlsym(dl->handle, buffer);