summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Sources/Network
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Sources/Network')
-rw-r--r--Kernel/Sources/Network/IPCEP.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/Kernel/Sources/Network/IPCEP.cxx b/Kernel/Sources/Network/IPCEP.cxx
index e3a40fb9..0cd9d778 100644
--- a/Kernel/Sources/Network/IPCEP.cxx
+++ b/Kernel/Sources/Network/IPCEP.cxx
@@ -5,3 +5,39 @@
------------------------------------------- */
#include <NetworkKit/IPCEP.hxx>
+
+using namespace NewOS;
+
+Bool ipc_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)
+ return false;
+
+ break;
+ }
+ case Endian::kEndianLittle:
+ {
+ if (pckt->IpcEndianess == eIPCEPBigEndian)
+ return false;
+
+ break;
+ }
+ case Endian::kEndianMixed:
+ break;
+ default:
+ return false;
+ }
+
+ if (pckt->IpcFrom == pckt->IpcTo) return false;
+ if (pckt->IpcPacketSize > cIPCEPMsgSize) return false;
+
+ return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic;
+}