namespace {
static pid_t const PID(getpid());
-static int const PORT(getpid() % 1000 + 2000);
static string const PID_STR(to_string(PID));
-static string const PORT_STR(to_string(PORT));
-static string const ADDRESS("0.0.0.0");
+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 int PORT;
+static string PORT_STR;
+
/// @brief Represents HTTP POST request with JSON body.
///
/// In addition to the requirements specified by the @ref PostHttpRequest
static bool initialized(DoInitialization());
assert(initialized);
- writeToFile(KEA_DHCP4_CONF, R"(
- {
- "Dhcp4": {
- "control-sockets": [
- {
- "socket-address": ")" + ADDRESS + R"(",
- "socket-port": )" + PORT_STR + R"(,
- "socket-type": "http"
- }
- ],
- "lease-database": {
- "name": ")" + KEA_DHCP4_CSV + R"(",
- "persist": false,
- "type": "memfile"
- }
- }
- }
- )");
+ setenv("KEA_DHCP4_FUZZING_ROTATE_PORT", "true", 0);
return 0;
}
LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) {
CfgMgr::instance().clear();
ControlledDhcpv4Srv server;
+
+ PORT = ControlledDhcpv4Srv::getInstance()->getServerPort();
+ PORT_STR = to_string(PORT);
+
+ writeToFile(KEA_DHCP4_CONF, R"(
+ {
+ "Dhcp4": {
+ "control-sockets": [
+ {
+ "socket-address": ")" + ADDRESS + R"(",
+ "socket-port": )" + PORT_STR + R"(,
+ "socket-type": "http"
+ }
+ ],
+ "lease-database": {
+ "name": ")" + KEA_DHCP4_CSV + R"(",
+ "persist": false,
+ "type": "memfile"
+ }
+ }
+ }
+ )");
+
server.init(KEA_DHCP4_CONF);
HttpClient client(ControlledDhcpv4Srv::getInstance()->getIOService(), false);
namespace {
static pid_t const PID(getpid());
-static int const PORT(getpid() % 1000 + 2000);
static string const PID_STR(to_string(PID));
-static string const PORT_STR(to_string(PORT));
-static string const ADDRESS("::");
+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 int PORT;
+static string PORT_STR;
+
/// @brief Represents HTTP POST request with JSON body.
///
/// In addition to the requirements specified by the @ref PostHttpRequest
static bool initialized(DoInitialization());
assert(initialized);
+ setenv("KEA_DHCP6_FUZZING_ROTATE_PORT", "true", 0);
+
+ return 0;
+}
+
+int
+LLVMFuzzerTearDown() {
+ try {
+ remove(KEA_DHCP6_CONF.c_str());
+ } catch (...) {
+ }
+ try {
+ remove(KEA_DHCP6_CSV.c_str());
+ } catch (...) {
+ }
+ return 0;
+}
+
+int
+LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) {
+ CfgMgr::instance().clear();
+ ControlledDhcpv6Srv server;
+
+ PORT = ControlledDhcpv6Srv::getInstance()->getServerPort();
+ PORT_STR = to_string(PORT);
+
writeToFile(KEA_DHCP6_CONF, R"(
{
"Dhcp6": {
}
)");
- return 0;
-}
-
-int
-LLVMFuzzerTearDown() {
- try {
- remove(KEA_DHCP6_CONF.c_str());
- } catch (...) {
- }
- try {
- remove(KEA_DHCP6_CSV.c_str());
- } catch (...) {
- }
- return 0;
-}
-
-int
-LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) {
- CfgMgr::instance().clear();
- ControlledDhcpv6Srv server;
server.init(KEA_DHCP6_CONF);
HttpClient client(ControlledDhcpv6Srv::getInstance()->getIOService(), false);
#!/bin/sh
-if ! sudo -n true; then exec sudo -E -- "${0}" "${@}"; fi
+if test "$(id -u)" != 0; then exec sudo -E -- "${0}" "${@}"; fi
script_path=$(cd "$(dirname "${0}")" && pwd)
#!/bin/sh
-if ! sudo -n true; then exec sudo -E -- "${0}" "${@}"; fi
+if test "$(id -u)" != 0; then exec sudo -E -- "${0}" "${@}"; fi
script_path=$(cd "$(dirname "${0}")" && pwd)
#!/bin/sh
-if ! sudo -n true; then exec sudo -E -- "${0}" "${@}"; fi
+if test "$(id -u)" != 0; then exec sudo -E -- "${0}" "${@}"; fi
script_path=$(cd "$(dirname "${0}")" && pwd)
#!/bin/sh
-if ! sudo -n true; then exec sudo -E -- "${0}" "${@}"; fi
+if test "$(id -u)" != 0; then exec sudo -E -- "${0}" "${@}"; fi
script_path=$(cd "$(dirname "${0}")" && pwd)
#!/bin/sh
-if ! sudo -n true; then exec sudo -E -- "${0}" "${@}"; fi
+if test "$(id -u)" != 0; then exec sudo -E -- "${0}" "${@}"; fi
script_path=$(cd "$(dirname "${0}")" && pwd)
#!/bin/sh
-if ! sudo -n true; then exec sudo -E -- "${0}" "${@}"; fi
+if test "$(id -u)" != 0; then exec sudo -E -- "${0}" "${@}"; fi
script_path=$(cd "$(dirname "${0}")" && pwd)
#!/bin/sh
-if ! sudo -n true; then exec sudo -E -- "${0}" "${@}"; fi
+if test "$(id -u)" != 0; then exec sudo -E -- "${0}" "${@}"; fi
script_path=$(cd "$(dirname "${0}")" && pwd)
#!/bin/sh
-if ! sudo -n true; then exec sudo -E -- "${0}" "${@}"; fi
+if test "$(id -u)" != 0; then exec sudo -E -- "${0}" "${@}"; fi
script_path=$(cd "$(dirname "${0}")" && pwd)
uint16_t Dhcpv4Srv::getServerPort() const {
#ifdef FUZZING
- char const* const randomize(getenv("KEA_DHCP4_FUZZING_ROTATE_PORT"));
- if (randomize) {
- InterprocessSyncFile file("kea-dhcp4-fuzzing-randomize-port");
+ char const* const rotate(getenv("KEA_DHCP4_FUZZING_ROTATE_PORT"));
+ if (rotate) {
+ InterprocessSyncFile file("kea-dhcp4-fuzzing-rotate-port");
InterprocessSyncLocker locker(file);
while (!locker.lock()) {
this_thread::sleep_for(1s);
uint16_t Dhcpv6Srv::getServerPort() const {
#ifdef FUZZING
- char const* const randomize(getenv("KEA_DHCP6_FUZZING_ROTATE_PORT"));
- if (randomize) {
- InterprocessSyncFile file("kea-dhcp6-fuzzing-randomize-port");
+ char const* const rotate(getenv("KEA_DHCP6_FUZZING_ROTATE_PORT"));
+ if (rotate) {
+ InterprocessSyncFile file("kea-dhcp6-fuzzing-rotate-port");
InterprocessSyncLocker locker(file);
while (!locker.lock()) {
this_thread::sleep_for(1s);