From da528b4815f06033af9ea0dd104e0e541155d863 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 5 Oct 2023 08:38:44 +0200 Subject: [PATCH] Some plausibility checks added --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index bcd562a..ad1eb45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use chrono::{DateTime, Duration, Local}; +use core::num; use log::debug; use std::{collections::HashMap, net::UdpSocket, thread}; @@ -168,6 +169,15 @@ fn main() -> std::io::Result<()> { } }; + // Just do the very least of plausibility checks + if number_of_bytes < 2 { + // Abort if not at least 2 bytes have been received + continue; + } else if (buf[0] >> 6) != 1u8 { + // Abort if protocol version is not "1" + continue; + } + let client_addr = src_addr.to_string(); let speed = buf[1] >> 2; let data = &buf[0..number_of_bytes];