Kernel: Use try_copy_kstring_from_user() in IPv4Socket::ioctl()

This commit is contained in:
Andreas Kling 2021-08-05 23:09:21 +02:00
parent 584fa525eb
commit b96ad76cba
Notes: sideshowbarker 2024-07-19 01:59:31 +09:00

View file

@ -589,11 +589,11 @@ KResult IPv4Socket::ioctl(FileDescription&, unsigned request, Userspace<void*> a
if (!copy_from_user(&route, user_route))
return EFAULT;
auto copied_ifname = copy_string_from_user(route.rt_dev, IFNAMSIZ);
if (copied_ifname.is_null())
return EFAULT;
auto ifname_or_error = try_copy_kstring_from_user(route.rt_dev, IFNAMSIZ);
if (ifname_or_error.is_error())
return ifname_or_error.error();
auto adapter = NetworkingManagement::the().lookup_by_name(copied_ifname);
auto adapter = NetworkingManagement::the().lookup_by_name(ifname_or_error.value()->view());
if (!adapter)
return ENODEV;