From 6ea68d219dc3a1bcc0deef1683e8442082025940 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Tue, 30 Jul 2024 10:01:42 +0200 Subject: [IMP] SCIKit: SharedInterface1 and UnknownInterface, both are defined in foreign SOs. [REFACTOR] IPCEP is just now IPC. Signed-off-by: Amlal EL Mahrouss --- Kernel/Sources/Network/IPC.cxx | 68 ++++++++++++++++++++++++++++++++++++++++ Kernel/Sources/Network/IPCEP.cxx | 68 ---------------------------------------- 2 files changed, 68 insertions(+), 68 deletions(-) create mode 100644 Kernel/Sources/Network/IPC.cxx delete mode 100644 Kernel/Sources/Network/IPCEP.cxx (limited to 'Kernel/Sources') diff --git a/Kernel/Sources/Network/IPC.cxx b/Kernel/Sources/Network/IPC.cxx new file mode 100644 index 00000000..12ec6c1a --- /dev/null +++ b/Kernel/Sources/Network/IPC.cxx @@ -0,0 +1,68 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#include +#include +#include + +using namespace Kernel; + +/// @internal +/// @brief The internal sanitize function. +Bool ipc_int_sanitize_packet(IPC_MESSAGE_STRUCT* pckt) +{ + auto endian = DEDUCE_ENDIAN(pckt, ((char*)pckt)[0]); + + switch (endian) + { + case Endian::kEndianBig: { + if (pckt->IpcEndianess == eIPCEPLittleEndian) + goto ipc_check_failed; + + break; + } + case Endian::kEndianLittle: { + if (pckt->IpcEndianess == eIPCEPBigEndian) + goto ipc_check_failed; + + break; + } + case Endian::kEndianMixed: + break; + default: + goto ipc_check_failed; + } + + if (pckt->IpcFrom == pckt->IpcTo || + pckt->IpcPacketSize > cIPCEPMsgSize) + { + goto ipc_check_failed; + } + + return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic; + +ipc_check_failed: + ErrLocal() = kErrorIPC; + return false; +} + +namespace Kernel +{ + /// @brief Sanitize packet function + /// @retval true packet is correct. + /// @retval false packet is incorrect and process has crashed. + Bool ipc_sanitize_packet(IPC_MESSAGE_STRUCT* pckt) + { + if (!pckt || + !ipc_int_sanitize_packet(pckt)) + { + ProcessScheduler::The().Leak().TheCurrent().Leak().Crash(); + return false; + } + + return true; + } +} // namespace Kernel diff --git a/Kernel/Sources/Network/IPCEP.cxx b/Kernel/Sources/Network/IPCEP.cxx deleted file mode 100644 index 5271be05..00000000 --- a/Kernel/Sources/Network/IPCEP.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#include -#include -#include - -using namespace Kernel; - -/// @internal -/// @brief The internal sanitize function. -Bool ipc_int_sanitize_packet(IPCEPMessageHeader* pckt) -{ - auto endian = DEDUCE_ENDIAN(pckt, ((char*)pckt)[0]); - - switch (endian) - { - case Endian::kEndianBig: { - if (pckt->IpcEndianess == eIPCEPLittleEndian) - goto ipc_check_failed; - - break; - } - case Endian::kEndianLittle: { - if (pckt->IpcEndianess == eIPCEPBigEndian) - goto ipc_check_failed; - - break; - } - case Endian::kEndianMixed: - break; - default: - goto ipc_check_failed; - } - - if (pckt->IpcFrom == pckt->IpcTo || - pckt->IpcPacketSize > cIPCEPMsgSize) - { - goto ipc_check_failed; - } - - return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic; - -ipc_check_failed: - ErrLocal() = kErrorIPC; - return false; -} - -namespace Kernel -{ - /// @brief Sanitize packet function - /// @retval true packet is correct. - /// @retval false packet is incorrect and process has crashed. - Bool ipc_sanitize_packet(IPCEPMessageHeader* pckt) - { - if (!pckt || - !ipc_int_sanitize_packet(pckt)) - { - ProcessScheduler::The().Leak().TheCurrent().Leak().Crash(); - return false; - } - - return true; - } -} // namespace Kernel -- cgit v1.2.3