diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-26 11:44:57 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-07-26 11:44:57 +0200 |
| commit | 8ba173ca8f2b6acc2868fc1066e3783ac8b52174 (patch) | |
| tree | bc40b8d8bd6837dd43deb4e89081bf2256c41e8a /Kernel/Sources | |
| parent | 14769b940725a9e323d237179e812ccfdae08382 (diff) | |
[IMP] Code improvements in IPCEP.cxx
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/Sources')
| -rw-r--r-- | Kernel/Sources/Network/IPCEP.cxx | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/Kernel/Sources/Network/IPCEP.cxx b/Kernel/Sources/Network/IPCEP.cxx index dcc8795c..54d94b18 100644 --- a/Kernel/Sources/Network/IPCEP.cxx +++ b/Kernel/Sources/Network/IPCEP.cxx @@ -12,45 +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: { if (pckt->IpcEndianess == eIPCEPLittleEndian) - goto _Fail; + goto ipc_check_failed; break; } 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) - { - goto _Fail; - } - if (pckt->IpcPacketSize > cIPCEPMsgSize) + if (pckt->IpcFrom == pckt->IpcTo || + pckt->IpcPacketSize > cIPCEPMsgSize) { - goto _Fail; + goto ipc_check_failed; } return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic; -_Fail: +ipc_check_failed: ErrLocal() = kErrorIPC; return false; } @@ -62,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; |
