mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2024-12-26 09:17:08 +00:00
Fix heap corruption in Rust bindings (#62)
RabbitizerInstruction_getSizeForBuffer and RabbitizerOperandType_getBufferSize return the size _without_ the null terminator, so we need to allocate one more byte to avoid writing past the allocated vector bounds.
This commit is contained in:
parent
f5c65d02d1
commit
4dd2a55588
@ -709,7 +709,7 @@ impl Instruction {
|
||||
let buffer_size =
|
||||
RabbitizerInstruction_getSizeForBuffer(self, imm_override_len, extra_l_just);
|
||||
|
||||
let mut buffer: Vec<u8> = vec![0; buffer_size];
|
||||
let mut buffer: Vec<u8> = vec![0; buffer_size + 1];
|
||||
let disassembled_size = RabbitizerInstruction_disassemble(
|
||||
self,
|
||||
buffer.as_mut_ptr() as *mut core::ffi::c_char,
|
||||
|
@ -30,7 +30,7 @@ impl operand_type_enum::OperandType {
|
||||
unsafe {
|
||||
let buffer_size = RabbitizerOperandType_getBufferSize(*self, instr, imm_override_len);
|
||||
|
||||
let mut buffer: Vec<u8> = vec![0; buffer_size];
|
||||
let mut buffer: Vec<u8> = vec![0; buffer_size + 1];
|
||||
let disassembled_size = RabbitizerOperandType_disassemble(
|
||||
*self,
|
||||
instr,
|
||||
|
Loading…
Reference in New Issue
Block a user