-// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
using namespace isc::util::file;
using namespace std;
-extern "C" {
+string KEA_FUZZ_DIR() {
+ static TemporaryDirectory TEMP_DIR = TemporaryDirectory();
+ return TEMP_DIR.dirName();
+}
-string KEA_LFC = isFile(KEA_LFC_INSTALLATION) ? KEA_LFC_INSTALLATION : KEA_LFC_SOURCES;
-// string KEA_FUZZ_DIR = isFile(KEA_FUZZ_DIR_INSTALLATION) ? KEA_FUZZ_DIR_INSTALLATION : KEA_FUZZ_DIR_SOURCES;
-TemporaryDirectory TEMP_DIR = TemporaryDirectory();
-string KEA_FUZZ_DIR = TEMP_DIR.dirName();
+extern "C" {
bool
DoInitialization() {
// Spoof the logger just enough to not get LoggingNotInitialized thrown.
// We explicitly don't want any logging during fuzzing for performance reasons.
- setenv("KEA_LOCKFILE_DIR", KEA_FUZZ_DIR.c_str(), 0);
+ setenv("KEA_LOCKFILE_DIR", KEA_FUZZ_DIR().c_str(), 0);
setenv("KEA_LFC_EXECUTABLE", "/bin/true", 0);
if (!getenv("DEBUG")) {
setenv("KEA_LOGGER_DESTINATION", "/dev/null", 0);
}
- setenv("KEA_PIDFILE_DIR", KEA_FUZZ_DIR.c_str(), 0);
+ setenv("KEA_PIDFILE_DIR", KEA_FUZZ_DIR().c_str(), 0);
if (!isc::log::isLoggingInitialized()) {
isc::log::initLogger("fuzzer");
Daemon::loggerInit("fuzzer", /* verbose = */ false);
-// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <string>
#include <vector>
-extern "C" {
+std::string KEA_FUZZ_DIR();
-extern std::string KEA_FUZZ_DIR;
-extern std::string KEA_LFC;
+extern "C" {
bool
DoInitialization();
-// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
static pid_t const PID(getpid());
static string const PID_STR(to_string(PID));
-static string const KEA_DHCP4_CONF(KEA_FUZZ_DIR + "/kea-dhcp4-" + PID_STR + ".conf");
+static string const KEA_DHCP4_CONF(KEA_FUZZ_DIR() + "/kea-dhcp4-" + PID_STR + ".conf");
} // namespace
-// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
static pid_t const PID(getpid());
static string const PID_STR(to_string(PID));
-static string const KEA_DHCP6_CONF(KEA_FUZZ_DIR + "/kea-dhcp6-" + PID_STR + ".conf");
+static string const KEA_DHCP6_CONF(KEA_FUZZ_DIR() + "/kea-dhcp6-" + PID_STR + ".conf");
} // namespace
-// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
static pid_t const PID(getpid());
static string const PID_STR(to_string(PID));
static string const ADDRESS("127.0.0.1");
-static string const KEA_DHCP4_CONF(KEA_FUZZ_DIR + "/kea-dhcp4-" + PID_STR + ".conf");
-static string const KEA_DHCP4_CSV(KEA_FUZZ_DIR + "/kea-dhcp4-" + PID_STR + ".csv");
+static string const KEA_DHCP4_CONF(KEA_FUZZ_DIR() + "/kea-dhcp4-" + PID_STR + ".conf");
+static string const KEA_DHCP4_CSV(KEA_FUZZ_DIR() + "/kea-dhcp4-" + PID_STR + ".csv");
static int PORT;
static string PORT_STR;
-// Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
static pid_t const PID(getpid());
static string const PID_STR(to_string(PID));
static string const ADDRESS("::1");
-static string const KEA_DHCP6_CONF(KEA_FUZZ_DIR + "/kea-dhcp6-" + PID_STR + ".conf");
-static string const KEA_DHCP6_CSV(KEA_FUZZ_DIR + "/kea-dhcp6-" + PID_STR + ".csv");
+static string const KEA_DHCP6_CONF(KEA_FUZZ_DIR() + "/kea-dhcp6-" + PID_STR + ".conf");
+static string const KEA_DHCP6_CSV(KEA_FUZZ_DIR() + "/kea-dhcp6-" + PID_STR + ".csv");
static int PORT;
static string PORT_STR;
namespace {
-static string const KEA_DHCP4_CONF(KEA_FUZZ_DIR + "/kea-dhcp4.conf");
+static string const KEA_DHCP4_CONF(KEA_FUZZ_DIR() + "/kea-dhcp4.conf");
static string KEA_DHCP4_FUZZING_INTERFACE;
static string KEA_DHCP4_FUZZING_ADDRESS;
namespace {
-static string const KEA_DHCP6_CONF(KEA_FUZZ_DIR + "/kea-dhcp6.conf");
+static string const KEA_DHCP6_CONF(KEA_FUZZ_DIR() + "/kea-dhcp6.conf");
static string KEA_DHCP6_FUZZING_INTERFACE;
static string KEA_DHCP6_FUZZING_ADDRESS;
#include <config/unix_command_config.h>
#include <dhcp4/ctrl_dhcp4_srv.h>
#include <dhcpsrv/cfgmgr.h>
+#include <testutils/env_var_wrapper.h>
#include <testutils/unix_control_client.h>
#include <util/filesystem.h>
#include <cassert>
+#include <cstdlib>
using namespace isc::asiolink;
using namespace isc::config;
using namespace isc::data;
using namespace isc::dhcp;
using namespace isc::dhcp::test;
+using namespace isc::test;
using namespace isc::util;
using namespace isc::util::file;
using namespace std;
static pid_t const PID(getpid());
static string const PID_STR(to_string(PID));
-static string const KEA_DHCP4_CONF(KEA_FUZZ_DIR + "/kea-dhcp4-" + PID_STR + ".conf");
-static string const KEA_DHCP4_CSV(KEA_FUZZ_DIR + "/kea-dhcp4-" + PID_STR + ".csv");
-static string const SOCKET(KEA_FUZZ_DIR + "/kea-dhcp4-ctrl-" + PID_STR + ".sock");
+static string const KEA_DHCP4_CONF(KEA_FUZZ_DIR() + "/kea-dhcp4-" + PID_STR + ".conf");
+static string const KEA_DHCP4_CSV(KEA_FUZZ_DIR() + "/kea-dhcp4-" + PID_STR + ".csv");
+static string const SOCKET(KEA_FUZZ_DIR() + "/kea-dhcp4-ctrl-" + PID_STR + ".sock");
static UnixControlClient TEST_CLIENT;
static pid_t const PID(getpid());
static string const PID_STR(to_string(PID));
-static string const KEA_DHCP6_CONF(KEA_FUZZ_DIR + "/kea-dhcp6-" + PID_STR + ".conf");
-static string const KEA_DHCP6_CSV(KEA_FUZZ_DIR + "/kea-dhcp6-" + PID_STR + ".csv");
-static string const SOCKET(KEA_FUZZ_DIR + "/kea-dhcp6-ctrl-" + PID_STR + ".sock");
+static string const KEA_DHCP6_CONF(KEA_FUZZ_DIR() + "/kea-dhcp6-" + PID_STR + ".conf");
+static string const KEA_DHCP6_CSV(KEA_FUZZ_DIR() + "/kea-dhcp6-" + PID_STR + ".csv");
+static string const SOCKET(KEA_FUZZ_DIR() + "/kea-dhcp6-ctrl-" + PID_STR + ".sock");
static UnixControlClient TEST_CLIENT;