🐛 bug: fix server crashing when you send it a packet of ":V\n"

main
_ 2021-12-09 01:46:03 +00:00
parent 33e6ae29ca
commit 2ba1dc2834
2 changed files with 7 additions and 5 deletions

View File

@ -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 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 I can't remember the trick for that. I think last time I did this
(for that work project) I just punted to Qt. (for that work project) I just punted to Qt.
# 01FPDWYH3ZY52DFF6PNRSA63GB
Sending an invalid packet directly to the server's UDP port crashes the server.

View File

@ -37,7 +37,13 @@ pub async fn server <I: Iterator <Item=String>> (mut args: I) -> Result <(), App
loop { loop {
println! ("Waiting for messages..."); 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 () { let req = match req_msgs.into_iter ().next () {
Some (x) => x, Some (x) => x,