mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: fix a corrupted stack caused by get_win_size
According to `asm-generic/termios.h`, the `struct winsize` should be:
struct winsize {
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel;
unsigned short ws_ypixel;
};
The ioctl of TIOCGWINSZ will trigger a segfault on aarch64.
Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
This commit is contained in:
@@ -265,14 +265,15 @@ type VirtioDeviceArc = Arc<Mutex<dyn vm_virtio::VirtioDevice>>;
|
|||||||
|
|
||||||
pub fn get_win_size() -> (u16, u16) {
|
pub fn get_win_size() -> (u16, u16) {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[derive(Default)]
|
||||||
struct WS {
|
struct WS {
|
||||||
rows: u16,
|
rows: u16,
|
||||||
cols: u16,
|
cols: u16,
|
||||||
|
xpixel: u16,
|
||||||
|
ypixel: u16,
|
||||||
};
|
};
|
||||||
let ws: WS = WS {
|
let ws: WS = WS::default();
|
||||||
rows: 0u16,
|
|
||||||
cols: 0u16,
|
|
||||||
};
|
|
||||||
unsafe {
|
unsafe {
|
||||||
libc::ioctl(0, TIOCGWINSZ, &ws);
|
libc::ioctl(0, TIOCGWINSZ, &ws);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user