Skip to content

Commit aa69436

Browse files
Fix i386 QEMU read_function_argument() (#1677)
1 parent a278357 commit aa69436

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libafl_qemu/src/i386.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ impl crate::ArchExtras for crate::CPU {
8080

8181
match idx {
8282
0..=1 => {
83-
let val: GuestReg = val.into();
8483
let stack_ptr: GuestAddr = self.read_reg(Regs::Sp)?;
8584
/*
8685
* Stack is full and descending. SP points to return address, arguments
@@ -89,10 +88,11 @@ impl crate::ArchExtras for crate::CPU {
8988
let size: GuestAddr = size_of::<GuestReg>() as GuestAddr;
9089
let offset = size * (idx as GuestAddr + 1);
9190

92-
let val = unsafe {
93-
self.read_mem(stack_ptr + offset, size_of::<GuestReg>());
94-
};
95-
Ok(GuestReg::from_le_bytes(val))
91+
let mut val = [0u8; size_of::<GuestReg>()];
92+
unsafe {
93+
self.read_mem(stack_ptr + offset, &mut val);
94+
}
95+
Ok(GuestReg::from_le_bytes(val).into())
9696
}
9797
_ => Err(format!("Unsupported argument: {idx:}")),
9898
}

0 commit comments

Comments
 (0)