Check License check for valid size instead of reading zeros
This commit is contained in:
parent
e4b6c0d519
commit
88354f74f8
|
@ -100,6 +100,10 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit
|
||||||
fn write_license_string(sec_writer: &mut dyn SectorWriter, license_file: &mut BufferedInputFile) -> Result<(), Error> {
|
fn write_license_string(sec_writer: &mut dyn SectorWriter, license_file: &mut BufferedInputFile) -> Result<(), Error> {
|
||||||
const LICENSE_STRING_START:u64 = 0x2488;
|
const LICENSE_STRING_START:u64 = 0x2488;
|
||||||
|
|
||||||
|
if license_file.get_ref().metadata()?.len() < LICENSE_STRING_START {
|
||||||
|
return Err(Error::from_str("License file to short to contain license string. Is this is a valid license file?"));
|
||||||
|
}
|
||||||
|
|
||||||
let mut license_string_buffer = [0u8; Mode2Form1::DATA_SIZE];
|
let mut license_string_buffer = [0u8; Mode2Form1::DATA_SIZE];
|
||||||
|
|
||||||
license_file.seek(SeekFrom::Start(LICENSE_STRING_START))?;
|
license_file.seek(SeekFrom::Start(LICENSE_STRING_START))?;
|
||||||
|
@ -119,6 +123,10 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit
|
||||||
for _ in 0..7 {
|
for _ in 0..7 {
|
||||||
const LICENSE_SECTOR_REST:i64 = 0x120;
|
const LICENSE_SECTOR_REST:i64 = 0x120;
|
||||||
|
|
||||||
|
if license_file.get_ref().metadata()?.len() < license_file.stream_position()? + LICENSE_SECTOR_REST as u64 {
|
||||||
|
return Err(Error::from_str("License file to short to contain license logo. Is this is a valid license file?"));
|
||||||
|
}
|
||||||
|
|
||||||
let mut license_logo_buffer = [0u8; Mode2Form1::DATA_SIZE];
|
let mut license_logo_buffer = [0u8; Mode2Form1::DATA_SIZE];
|
||||||
|
|
||||||
license_file.read(&mut license_logo_buffer)?;
|
license_file.read(&mut license_logo_buffer)?;
|
||||||
|
|
Loading…
Reference in New Issue