From b8d25fdb7bf38fcfb6ae65820e59fc157cf028c7 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 15 Sep 2019 14:37:31 +0200 Subject: Check for minimum length of request --- src/tftpd.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tftpd.rs b/src/tftpd.rs index 102063d..6513367 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -181,6 +181,11 @@ impl Tftpd { socket.set_read_timeout(Some(Duration::from_secs(5)))?; socket.connect(cl)?; + if buf.len() < 2 { + self.tftp.send_error(&socket, 0, "Invalid request length")?; + return Err(io::Error::new(io::ErrorKind::Other, "invalid request length")); + } + match u16::from_be_bytes([buf[0], buf[1]]) { // opcode o if o == rtftp::Opcode::RRQ as u16 => { if self.conf.wo { -- cgit v1.2.3