summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Services/DHCPClient/DHCPv4.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Services/DHCPClient/DHCPv4.h b/Userland/Services/DHCPClient/DHCPv4.h
index b3165633b4..7e87f84250 100644
--- a/Userland/Services/DHCPClient/DHCPv4.h
+++ b/Userland/Services/DHCPClient/DHCPv4.h
@@ -114,7 +114,7 @@ struct AK::Traits<DHCPOption> : public GenericTraits<DHCPOption> {
struct ParsedDHCPv4Options {
template<typename T>
- Optional<const T> get(DHCPOption option_name) const
+ Optional<const T> get(DHCPOption option_name) const requires(IsTriviallyCopyable<T>)
{
auto option = options.get(option_name);
if (!option.has_value()) {
@@ -123,7 +123,9 @@ struct ParsedDHCPv4Options {
auto& value = option.value();
if (value.length != sizeof(T))
return {};
- return *(const T*)value.value;
+ T t;
+ __builtin_memcpy(&t, value.value, value.length);
+ return t;
}
template<typename T>