mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
check UDP packet's data length before decrypt_packet
fixes shadowsocks/crypto2#8
This commit is contained in:
@@ -219,6 +219,10 @@ async fn decrypt_payload_aead(
|
||||
let mut cipher = Cipher::new(method, &key, &salt);
|
||||
let tag_len = cipher.tag_len();
|
||||
|
||||
if data.len() < tag_len {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "udp packet too short for tag"));
|
||||
}
|
||||
|
||||
if !cipher.decrypt_packet(data) {
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "invalid tag-in"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user