summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2024-10-22 09:50:35 +0200
committerAndrei Pavel <andrei@isc.org>2024-10-23 15:40:31 +0200
commita4f4e30b3d809dbb0027f63ef9c35c5a4365e3dc (patch)
tree32433d89d6028b1ef90bf46eb44ce149857242ca
parent[#3605] Integrate a new fuzzing solution in Kea (diff)
downloadkea-a4f4e30b3d809dbb0027f63ef9c35c5a4365e3dc.tar.xz
kea-a4f4e30b3d809dbb0027f63ef9c35c5a4365e3dc.zip
[#3605] Razvan's fix for ASAN warnings in fuzzing
-rw-r--r--fuzz/fuzz_http_endpoint.cc3
-rw-r--r--fuzz/main.cc10
2 files changed, 11 insertions, 2 deletions
diff --git a/fuzz/fuzz_http_endpoint.cc b/fuzz/fuzz_http_endpoint.cc
index d9ef1e0834..ddddd77f8d 100644
--- a/fuzz/fuzz_http_endpoint.cc
+++ b/fuzz/fuzz_http_endpoint.cc
@@ -164,8 +164,9 @@ LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) {
}
}
listener.stop();
- io_service->poll();
client.stop();
+ run_io_service_timer.cancel();
+ io_service->poll();
MultiThreadingMgr::instance().setMode(false);
return 0;
diff --git a/fuzz/main.cc b/fuzz/main.cc
index b08abaf938..c3d8f2606c 100644
--- a/fuzz/main.cc
+++ b/fuzz/main.cc
@@ -6,14 +6,17 @@
#include <config.h>
+#include <exceptions/exceptions.h>
#include <util/filesystem.h>
#include <fuzz.h>
#include <cassert>
#include <cstdio>
+#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
+#include <memory>
#include <sstream>
#include <vector>
@@ -22,6 +25,7 @@
#include <sys/types.h>
#include <unistd.h>
+using namespace isc;
using namespace isc::util::file;
using namespace std;
@@ -52,7 +56,11 @@ main(int, char* argv[]) {
list<string> files;
struct dirent *dp;
- DIR *dfd(opendir(p.str().c_str()));
+ DIR *dfd(opendir(directory.c_str()));
+ if (!dfd) {
+ isc_throw(Unexpected, "opendir failed " << directory << ": " << strerror(errno));
+ }
+ std::unique_ptr<DIR, void(*)(DIR*)> defer(dfd, [](DIR* d) { closedir(d); });
while ((dp = readdir(dfd)) != nullptr) {
string file(dp->d_name);
if (file == "." || file == "..") {