1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 11:14:58 +00:00

Kernel: Use try_copy_kstring_from_user() in Socket::setsockopt()

This commit is contained in:
Andreas Kling 2021-08-05 23:10:14 +02:00
parent b96ad76cba
commit 5b13af0edd

View file

@ -108,10 +108,10 @@ KResult Socket::setsockopt(int level, int option, Userspace<const void*> user_va
if (user_value_size != IFNAMSIZ)
return EINVAL;
auto user_string = static_ptr_cast<const char*>(user_value);
auto ifname = copy_string_from_user(user_string, user_value_size);
if (ifname.is_null())
return EFAULT;
auto device = NetworkingManagement::the().lookup_by_name(ifname);
auto ifname_or_error = try_copy_kstring_from_user(user_string, user_value_size);
if (ifname_or_error.is_error())
return ifname_or_error.error();
auto device = NetworkingManagement::the().lookup_by_name(ifname_or_error.value()->view());
if (!device)
return ENODEV;
m_bound_interface = device;