From 2ba1dc283428299ac3093320554536428b038b95 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Thu, 9 Dec 2021 01:46:03 +0000 Subject: [PATCH] :bug: bug: fix server crashing when you send it a packet of ":V\n" --- issues.md | 4 ---- src/server.rs | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/issues.md b/issues.md index f118957..7889177 100644 --- a/issues.md +++ b/issues.md @@ -21,7 +21,3 @@ and get their IPs, so I might have to find another dependency for that. I think on Linux I can get it from `/sys/class/net` but I can't remember the trick for that. I think last time I did this (for that work project) I just punted to Qt. - -# 01FPDWYH3ZY52DFF6PNRSA63GB - -Sending an invalid packet directly to the server's UDP port crashes the server. diff --git a/src/server.rs b/src/server.rs index d61a226..45b9595 100644 --- a/src/server.rs +++ b/src/server.rs @@ -37,7 +37,13 @@ pub async fn server > (mut args: I) -> Result <(), App loop { println! ("Waiting for messages..."); - let (req_msgs, remote_addr) = recv_msg_from (&socket).await?; + let (req_msgs, remote_addr) = match recv_msg_from (&socket).await { + Ok (x) => x, + Err (e) => { + println! ("Error while receiving message: {:?}", e); + continue; + }, + }; let req = match req_msgs.into_iter ().next () { Some (x) => x,