mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-28 16:29:45 +00:00
vsock: don't panic if "connect PORT\n" is malformed
Instead of panic if the local peer doesn't send "connect PORT\n" correctly, let's print an error, ignoring the command. Print an error message also when allocating local port fails. Reported-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This commit is contained in:
parent
d6775cd90d
commit
5986155c8a
@ -208,12 +208,19 @@ impl VhostUserVsockThread {
|
||||
let mut unix_stream = self.thread_backend.stream_map.remove(&fd).unwrap();
|
||||
|
||||
// Local peer is sending a "connect PORT\n" command
|
||||
let peer_port = Self::read_local_stream_port(&mut unix_stream).unwrap();
|
||||
let peer_port = match Self::read_local_stream_port(&mut unix_stream) {
|
||||
Ok(port) => port,
|
||||
Err(err) => {
|
||||
warn!("Error while parsing \"connect PORT\n\" command: {:?}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// Allocate a local port number
|
||||
let local_port = match self.allocate_local_port() {
|
||||
Ok(lp) => lp,
|
||||
Err(_) => {
|
||||
Err(err) => {
|
||||
warn!("Error while allocating local port: {:?}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user