add extra validation for .bin function_offset_table_offset

This commit is contained in:
Gered 2021-05-25 10:51:45 -04:00
parent d9e13fade0
commit bf62db4507

View file

@ -110,6 +110,12 @@ impl QuestBin {
}
let function_offset_table_offset = reader.read_u32::<LittleEndian>()?;
if function_offset_table_offset <= object_code_offset {
return Err(QuestBinError::DataFormatError(format!(
"function_offset_table_offset points to a location that occurs before the object_code"
)));
}
let bin_size = reader.read_u32::<LittleEndian>()?;
let _xfffffff = reader.read_u32::<LittleEndian>()?; // always expected to be 0xffffffff
let is_download = reader.read_u8()?;