summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-12-17 09:12:20 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-18 11:30:10 +0100
commitabf22044028291769e5a7cddd6a2d8af0f4fedb0 (patch)
tree7142b29e57d8ed415e5926059dc5fbca7bacbef3 /Kernel/Net
parent39d9337db5056c9d8c9eb17cbceb6cec0b627510 (diff)
downloadserenity-abf22044028291769e5a7cddd6a2d8af0f4fedb0.zip
Kernel: Use copy_typed_from_user() in more places :^)
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/Socket.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp
index 224e9bcc7c..ba0b75abf1 100644
--- a/Kernel/Net/Socket.cpp
+++ b/Kernel/Net/Socket.cpp
@@ -112,23 +112,17 @@ ErrorOr<void> Socket::setsockopt(int level, int option, Userspace<const void*> u
case SO_TIMESTAMP:
if (user_value_size != sizeof(int))
return EINVAL;
- {
- int timestamp;
- TRY(copy_from_user(&timestamp, static_ptr_cast<const int*>(user_value)));
- m_timestamp = timestamp;
- }
- if (m_timestamp && (domain() != AF_INET || type() == SOCK_STREAM)) {
+ m_timestamp = TRY(copy_typed_from_user(static_ptr_cast<int const*>(user_value)));
+ if (m_timestamp != 0 && (domain() != AF_INET || type() == SOCK_STREAM)) {
// FIXME: Support SO_TIMESTAMP for more protocols?
m_timestamp = 0;
return ENOTSUP;
}
return {};
case SO_DONTROUTE: {
- int routing_disabled;
- if (user_value_size != sizeof(routing_disabled))
+ if (user_value_size != sizeof(int))
return EINVAL;
- TRY(copy_from_user(&routing_disabled, static_ptr_cast<const int*>(user_value)));
- m_routing_disabled = routing_disabled != 0;
+ m_routing_disabled = TRY(copy_typed_from_user(static_ptr_cast<int const*>(user_value))) != 0;
return {};
}
default: