diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-07-28 16:11:46 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-07-28 16:11:46 +0000 |
| commit | c4023005e029ae092dad2689564c490580dd5c28 (patch) | |
| tree | 3080ba07a6b552bf3d7591574cf69b2a3c8fd0fd /Kernel/Sources/Network | |
| parent | 8c8822fff78f9ff9cd640271da9b3634c4c2f97f (diff) | |
| parent | 4db57a2d646b1538783a0675b38bada7a0f903ae (diff) | |
Merged in MHR-36 (pull request #17)
MHR-36
Diffstat (limited to 'Kernel/Sources/Network')
| -rw-r--r-- | Kernel/Sources/Network/IP.cxx | 6 | ||||
| -rw-r--r-- | Kernel/Sources/Network/IPCEP.cxx | 34 | ||||
| -rw-r--r-- | Kernel/Sources/Network/NetworkDevice.cxx | 2 |
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 ------------------------------------------- */ |
