summaryrefslogtreecommitdiff
path: root/Userland/Services/DHCPClient
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-21 11:01:55 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-21 11:01:55 +0100
commit86a3363ddfa4ad8c6b4b71a07383563a9669f424 (patch)
treefc434cdc91e46d5b37a9478a82f59f8dcdaa1462 /Userland/Services/DHCPClient
parente928022bb3ae8e90e83463e85aad14d0a7ed7e7d (diff)
downloadserenity-86a3363ddfa4ad8c6b4b71a07383563a9669f424.zip
DHCPClient: Actually randomize transaction ID's (XID)
We were using unseeded rand() for the XID, which meant that our DHCP XID's were 100% predictable. Switch to using AK::get_random<u32>() instead. :^)
Diffstat (limited to 'Userland/Services/DHCPClient')
-rw-r--r--Userland/Services/DHCPClient/DHCPv4Client.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp
index 895b1467c8..74ddb40ee4 100644
--- a/Userland/Services/DHCPClient/DHCPv4Client.cpp
+++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp
@@ -29,6 +29,7 @@
#include <AK/Debug.h>
#include <AK/Endian.h>
#include <AK/Function.h>
+#include <AK/Random.h>
#include <LibCore/SocketAddress.h>
#include <LibCore/Timer.h>
#include <stdio.h>
@@ -239,7 +240,7 @@ void DHCPv4Client::process_incoming(const DHCPv4Packet& packet)
void DHCPv4Client::dhcp_discover(const InterfaceDescriptor& iface, IPv4Address previous)
{
- auto transaction_id = rand();
+ auto transaction_id = get_random<u32>();
if constexpr (DHCPV4CLIENT_DEBUG) {
dbgln("Trying to lease an IP for {} with ID {}", iface.m_ifname, transaction_id);