Some plausibility checks added
This commit is contained in:
parent
233f70af28
commit
da528b4815
1 changed files with 10 additions and 0 deletions
10
src/main.rs
10
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];
|
||||
|
|
Loading…
Reference in a new issue