From 4af29e8eca0c934219273ac29e1e865a585881bd Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 20 Jul 2020 19:07:12 +0800 Subject: [PATCH] comms: report error on incorrect connection start pattern --- src/runtime/src/comms.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/runtime/src/comms.rs b/src/runtime/src/comms.rs index db9b7e0..26edddd 100644 --- a/src/runtime/src/comms.rs +++ b/src/runtime/src/comms.rs @@ -263,7 +263,9 @@ async fn load_kernel(buffer: Vec, control: &Rc>, st } async fn handle_connection(stream: &TcpStream, control: Rc>) -> Result<()> { - expect(stream, b"ARTIQ coredev\n").await?; + if !expect(stream, b"ARTIQ coredev\n").await? { + return Err(Error::UnexpectedPattern); + } info!("received connection"); loop { let request = read_request(stream, true).await?;