filter disallowed bindings for the TcpListener

This commit is contained in:
bunnie 2022-08-02 16:44:37 +08:00
parent 81d5718f05
commit f2193d64b1

View file

@ -27,6 +27,12 @@ pub(crate) fn std_tcp_listen(
return;
}
};
if address.as_bytes() != [0, 0, 0, 0]
&& address.as_bytes() != [127, 0, 0, 1]
&& address.as_bytes() != IPV4_ADDRESS.load(Ordering::SeqCst).to_be_bytes() {
std_failure(msg, NetError::Invalid);
return;
}
let tcp_rx_buffer = TcpSocketBuffer::new(vec![0; TCP_BUFFER_SIZE]);
let tcp_tx_buffer = TcpSocketBuffer::new(vec![0; TCP_BUFFER_SIZE]);