mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
Kernel: Use copy_typed_from_user() in more places :^)
This commit is contained in:
parent
39d9337db5
commit
abf2204402
9 changed files with 41 additions and 66 deletions
|
@ -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(×tamp, 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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue