From 7f0c39fe916dfd7e367c848bf4918ca1e9532381 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 19 Sep 2024 22:51:55 +0300 Subject: [PATCH] Kernel: Don't crash the kernel if packet is smaller than ethernet hdr --- kernel/kernel/Networking/NetworkManager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/kernel/Networking/NetworkManager.cpp b/kernel/kernel/Networking/NetworkManager.cpp index 733ec5efdc..1f5f876fe1 100644 --- a/kernel/kernel/Networking/NetworkManager.cpp +++ b/kernel/kernel/Networking/NetworkManager.cpp @@ -121,6 +121,8 @@ namespace Kernel void NetworkManager::on_receive(NetworkInterface& interface, BAN::ConstByteSpan packet) { + if (packet.size() < sizeof(EthernetHeader)) + return; auto ethernet_header = packet.as(); switch (ethernet_header.ether_type)