Some plausibility checks added

This commit is contained in:
Martin Brodbeck 2023-10-05 08:38:44 +02:00
parent 233f70af28
commit da528b4815

View file

@ -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];