diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-05-06 08:37:46 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-06 08:49:35 +0200 |
commit | 6e101adc28c9c682f023386831d632a477768cb8 (patch) | |
tree | 6c3ecba97b2a98cb646157170923c3d71936295a | |
parent | 9213d1e92686ad650aa093e7e853b3996c926779 (diff) | |
download | serenity-6e101adc28c9c682f023386831d632a477768cb8.zip |
DHCPClient: Handle invalid DHCP responses more gracefully
-rw-r--r-- | Userland/Services/DHCPClient/DHCPv4Client.cpp | 6 |
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); |