mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 20:15:07 +00:00
Kernel: Use try_copy_kstring_from_user() in Socket::setsockopt()
This commit is contained in:
parent
b96ad76cba
commit
5b13af0edd
1 changed files with 4 additions and 4 deletions
|
@ -108,10 +108,10 @@ KResult Socket::setsockopt(int level, int option, Userspace<const void*> user_va
|
||||||
if (user_value_size != IFNAMSIZ)
|
if (user_value_size != IFNAMSIZ)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
auto user_string = static_ptr_cast<const char*>(user_value);
|
auto user_string = static_ptr_cast<const char*>(user_value);
|
||||||
auto ifname = copy_string_from_user(user_string, user_value_size);
|
auto ifname_or_error = try_copy_kstring_from_user(user_string, user_value_size);
|
||||||
if (ifname.is_null())
|
if (ifname_or_error.is_error())
|
||||||
return EFAULT;
|
return ifname_or_error.error();
|
||||||
auto device = NetworkingManagement::the().lookup_by_name(ifname);
|
auto device = NetworkingManagement::the().lookup_by_name(ifname_or_error.value()->view());
|
||||||
if (!device)
|
if (!device)
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
m_bound_interface = device;
|
m_bound_interface = device;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue