Skip to content

Commit 9af1ba2

Browse files
phip1611ShadowCurse
authored andcommitted
kvm-ioctls: improve get_nested_state()
Make the function more fail-safe. Signed-off-by: Philipp Schuster <[email protected]> On-behalf-of: SAP [email protected]
1 parent 057b16e commit 9af1ba2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kvm-ioctls/src/ioctls/vcpu.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,8 @@ impl VcpuFd {
20302030
match ret {
20312031
0 => {
20322032
let size = buffer.size as usize;
2033-
if size == size_of::<kvm_nested_state /* just the empty header */>() {
2033+
let just_hdr_size = size_of::<kvm_nested_state>();
2034+
if size <= just_hdr_size {
20342035
Ok(None)
20352036
} else {
20362037
Ok(Some(NonZeroUsize::new(size).unwrap()))

0 commit comments

Comments
 (0)