mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-25 00:54:32 +00:00
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
This commit is contained in:
committed by
Andreas Kling
parent
1259dc3623
commit
cf271183b4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user