fix(#289): crash due to invalid UDP socks5 packet received

This commit is contained in:
Σrebe - Romain GERARD 2024-06-07 20:53:08 +02:00
parent 2dd99130fa
commit 0da43e1643
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4

View file

@ -241,7 +241,14 @@ pub async fn run_server(
let (destination_addr, data) = {
let payload = buf.split().freeze();
let (frag, destination_addr, data) = fast_socks5::parse_udp_request(payload.chunk()).await.unwrap();
let (frag, destination_addr, data) = match fast_socks5::parse_udp_request(payload.chunk()).await {
Ok((frag, addr, data)) => (frag, addr, data),
Err(err) => {
warn!("Skipping invalid UDP socks5 request: {} ", err);
debug!("Invalid UDP socks5 request: {:?}", payload.chunk());
continue;
}
};
// We don't support udp fragmentation
if frag != 0 {
warn!("dropping UDP socks5 fragmented");