summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Sources/Network
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Sources/Network')
-rw-r--r--Kernel/Sources/Network/IP.cxx6
-rw-r--r--Kernel/Sources/Network/IPCEP.cxx34
-rw-r--r--Kernel/Sources/Network/NetworkDevice.cxx2
3 files changed, 18 insertions, 24 deletions
diff --git a/Kernel/Sources/Network/IP.cxx b/Kernel/Sources/Network/IP.cxx
index 676e12a8..64da3448 100644
--- a/Kernel/Sources/Network/IP.cxx
+++ b/Kernel/Sources/Network/IP.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
@@ -90,13 +90,13 @@ namespace Kernel
return true;
}
- ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress6> ipv6)
+ ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress6>& ipv6)
{
auto str = StringBuilder::Construct(ipv6.Leak().Address());
return str;
}
- ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress> ipv4)
+ ErrorOr<StringView> IPFactory::ToStringView(Ref<RawIPAddress>& ipv4)
{
auto str = StringBuilder::Construct(ipv4.Leak().Address());
return str;
diff --git a/Kernel/Sources/Network/IPCEP.cxx b/Kernel/Sources/Network/IPCEP.cxx
index 1869035b..54d94b18 100644
--- a/Kernel/Sources/Network/IPCEP.cxx
+++ b/Kernel/Sources/Network/IPCEP.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
@@ -12,46 +12,39 @@ using namespace Kernel;
/// @internal
/// @brief The internal sanitize function.
-Bool __ipc_sanitize_packet(IPCEPMessageHeader* pckt)
+Bool ipc_int_sanitize_packet(IPCEPMessageHeader* pckt)
{
- if (!pckt) return false;
-
auto endian = DEDUCE_ENDIAN(pckt, ((char*)pckt)[0]);
switch (endian)
{
- case Endian::kEndianBig:
- {
+ case Endian::kEndianBig: {
if (pckt->IpcEndianess == eIPCEPLittleEndian)
- goto _Fail;
+ goto ipc_check_failed;
break;
}
- case Endian::kEndianLittle:
- {
+ case Endian::kEndianLittle: {
if (pckt->IpcEndianess == eIPCEPBigEndian)
- goto _Fail;
+ goto ipc_check_failed;
break;
}
case Endian::kEndianMixed:
break;
default:
- goto _Fail;
+ goto ipc_check_failed;
}
- if (pckt->IpcFrom == pckt->IpcTo)
+ if (pckt->IpcFrom == pckt->IpcTo ||
+ pckt->IpcPacketSize > cIPCEPMsgSize)
{
- goto _Fail;
- }
- if (pckt->IpcPacketSize > cIPCEPMsgSize)
- {
- goto _Fail;
+ goto ipc_check_failed;
}
return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic;
-_Fail:
+ipc_check_failed:
ErrLocal() = kErrorIPC;
return false;
}
@@ -63,7 +56,8 @@ namespace Kernel
/// @retval false packet is incorrect and process has crashed.
Bool ipc_sanitize_packet(IPCEPMessageHeader* pckt)
{
- if (!__ipc_sanitize_packet(pckt))
+ if (!pckt ||
+ !ipc_int_sanitize_packet(pckt))
{
ProcessScheduler::The().Leak().TheCurrent().Leak().Crash();
return false;
@@ -71,4 +65,4 @@ namespace Kernel
return true;
}
-}
+} // namespace Kernel
diff --git a/Kernel/Sources/Network/NetworkDevice.cxx b/Kernel/Sources/Network/NetworkDevice.cxx
index 4ee633e8..7c61460e 100644
--- a/Kernel/Sources/Network/NetworkDevice.cxx
+++ b/Kernel/Sources/Network/NetworkDevice.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */