diff options
Diffstat (limited to 'Kernel/Sources')
| -rw-r--r-- | Kernel/Sources/HError.cxx | 2 | ||||
| -rw-r--r-- | Kernel/Sources/Network/IPCEP.cxx | 40 |
2 files changed, 35 insertions, 7 deletions
diff --git a/Kernel/Sources/HError.cxx b/Kernel/Sources/HError.cxx index 5ba02049..d38f2e07 100644 --- a/Kernel/Sources/HError.cxx +++ b/Kernel/Sources/HError.cxx @@ -11,7 +11,7 @@ namespace NewOS /// @brief Doea a system wide bug check. /// @param void no params. /// @return if error-free: true, otherwise false. - Boolean ke_bug_check(void) noexcept + Boolean err_bug_check(void) noexcept { /// TODO: return false; diff --git a/Kernel/Sources/Network/IPCEP.cxx b/Kernel/Sources/Network/IPCEP.cxx index 0cd9d778..9e198385 100644 --- a/Kernel/Sources/Network/IPCEP.cxx +++ b/Kernel/Sources/Network/IPCEP.cxx @@ -5,10 +5,14 @@ ------------------------------------------- */ #include <NetworkKit/IPCEP.hxx> +#include <KernelKit/HError.hpp> +#include <KernelKit/ProcessScheduler.hxx> using namespace NewOS; -Bool ipc_sanitize_packet(IPCEPMessageHeader* pckt) +/// @internal +/// @brief The internal sanitize function. +Bool __ipc_sanitize_packet(IPCEPMessageHeader* pckt) { if (!pckt) return false; @@ -19,25 +23,49 @@ Bool ipc_sanitize_packet(IPCEPMessageHeader* pckt) case Endian::kEndianBig: { if (pckt->IpcEndianess == eIPCEPLittleEndian) - return false; + goto _Fail; break; } case Endian::kEndianLittle: { if (pckt->IpcEndianess == eIPCEPBigEndian) - return false; + goto _Fail; break; } case Endian::kEndianMixed: break; default: - return false; + goto _Fail; } - if (pckt->IpcFrom == pckt->IpcTo) return false; - if (pckt->IpcPacketSize > cIPCEPMsgSize) return false; + if (pckt->IpcFrom == pckt->IpcTo) + { + goto _Fail; + } + if (pckt->IpcPacketSize > cIPCEPMsgSize) + { + goto _Fail; + } return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic; + +_Fail: + ErrLocal() = kErrorIPC; + return false; +} + +/// @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 (!__ipc_sanitize_packet(pckt)) + { + ProcessScheduler::The().Leak().TheCurrent().Leak().Crash(); + return false; + } + + return true; } |
