summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Sources/Network
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Sources/Network')
-rw-r--r--Kernel/Sources/Network/IPCEP.cxx40
1 files changed, 34 insertions, 6 deletions
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;
}