diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-08-19 22:45:07 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-19 23:49:53 +0200 |
commit | cf271183b4befeba7c96bd6ca25246b899e836bb (patch) | |
tree | 0361e7378750c2c4e45e5e01e273d6fe416555af /Kernel/Net/IPv4Socket.cpp | |
parent | 1259dc362376e8011d20d4d9e2fcc49d5b7f9dc9 (diff) | |
download | serenity-cf271183b4befeba7c96bd6ca25246b899e836bb.zip |
Kernel: Make Process::current() return a Process& instead of Process*
This has several benefits:
1) We no longer just blindly derefence a null pointer in various places
2) We will get nicer runtime error messages if the current process does
turn out to be null in the call location
3) GCC no longer complains about possible nullptr dereferences when
compiling without KUBSAN
Diffstat (limited to 'Kernel/Net/IPv4Socket.cpp')
-rw-r--r-- | Kernel/Net/IPv4Socket.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 9ca1731153..7b5c50c7a2 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -118,9 +118,9 @@ KResult IPv4Socket::bind(Userspace<const sockaddr*> user_address, socklen_t addr return set_so_error(EINVAL); auto requested_local_port = ntohs(address.sin_port); - if (!Process::current()->is_superuser()) { + if (!Process::current().is_superuser()) { if (requested_local_port > 0 && requested_local_port < 1024) { - dbgln("UID {} attempted to bind {} to port {}", Process::current()->uid(), class_name(), requested_local_port); + dbgln("UID {} attempted to bind {} to port {}", Process::current().uid(), class_name(), requested_local_port); return set_so_error(EACCES); } } @@ -603,7 +603,7 @@ KResult IPv4Socket::ioctl(FileDescription&, unsigned request, Userspace<void*> a switch (request) { case SIOCADDRT: - if (!Process::current()->is_superuser()) + if (!Process::current().is_superuser()) return EPERM; if (route.rt_gateway.sa_family != AF_INET) return EAFNOSUPPORT; @@ -628,7 +628,7 @@ KResult IPv4Socket::ioctl(FileDescription&, unsigned request, Userspace<void*> a switch (request) { case SIOCSARP: - if (!Process::current()->is_superuser()) + if (!Process::current().is_superuser()) return EPERM; if (arp_req.arp_pa.sa_family != AF_INET) return EAFNOSUPPORT; @@ -636,7 +636,7 @@ KResult IPv4Socket::ioctl(FileDescription&, unsigned request, Userspace<void*> a return KSuccess; case SIOCDARP: - if (!Process::current()->is_superuser()) + if (!Process::current().is_superuser()) return EPERM; if (arp_req.arp_pa.sa_family != AF_INET) return EAFNOSUPPORT; @@ -663,7 +663,7 @@ KResult IPv4Socket::ioctl(FileDescription&, unsigned request, Userspace<void*> a switch (request) { case SIOCSIFADDR: - if (!Process::current()->is_superuser()) + if (!Process::current().is_superuser()) return EPERM; if (ifr.ifr_addr.sa_family != AF_INET) return EAFNOSUPPORT; @@ -671,7 +671,7 @@ KResult IPv4Socket::ioctl(FileDescription&, unsigned request, Userspace<void*> a return KSuccess; case SIOCSIFNETMASK: - if (!Process::current()->is_superuser()) + if (!Process::current().is_superuser()) return EPERM; if (ifr.ifr_addr.sa_family != AF_INET) return EAFNOSUPPORT; |