summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-06 08:37:46 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-06 08:49:35 +0200
commit6e101adc28c9c682f023386831d632a477768cb8 (patch)
tree6c3ecba97b2a98cb646157170923c3d71936295a
parent9213d1e92686ad650aa093e7e853b3996c926779 (diff)
downloadserenity-6e101adc28c9c682f023386831d632a477768cb8.zip
DHCPClient: Handle invalid DHCP responses more gracefully
-rw-r--r--Userland/Services/DHCPClient/DHCPv4Client.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp
index 426cec15c1..a75538372f 100644
--- a/Userland/Services/DHCPClient/DHCPv4Client.cpp
+++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp
@@ -287,7 +287,11 @@ void DHCPv4Client::process_incoming(const DHCPv4Packet& packet)
dbgln_if(DHCPV4CLIENT_DEBUG, "Here are the options: {}", options.to_string());
- auto value = options.get<DHCPMessageType>(DHCPOption::DHCPMessageType).value();
+ auto value_or_error = options.get<DHCPMessageType>(DHCPOption::DHCPMessageType);
+ if (!value_or_error.has_value())
+ return;
+
+ auto value = value_or_error.value();
switch (value) {
case DHCPMessageType::DHCPOffer:
handle_offer(packet, options);