Ubi DAT: Additional checks

This commit is contained in:
NicknineTheEagle 2020-05-31 23:45:51 +03:00
parent e4eb650cfa
commit 8d2fcdbae3

View File

@ -656,11 +656,19 @@ static int parse_dat_header(ubi_sb_header *sb, STREAMFILE *sf) {
sb->section1_num = read_32bit(0x08, sf); sb->section1_num = read_32bit(0x08, sf);
sb->section2_offset = read_32bit(0x0c, sf); sb->section2_offset = read_32bit(0x0c, sf);
sb->section2_num = read_32bit(0x10, sf); sb->section2_num = read_32bit(0x10, sf);
sb->section3_offset = read_32bit(0x14, sf); sb->bank_size = read_32bit(0x14, sf);
sb->section3_num = 0;
if (sb->section1_offset != 0x18)
goto fail;
if (sb->section2_offset != sb->section1_offset + sb->section1_num * sb->cfg.section1_entry_size)
goto fail;
if (sb->bank_size != get_streamfile_size(sf))
goto fail;
sb->sectionX_offset = sb->section2_offset + sb->section2_num * sb->cfg.section2_entry_size; sb->sectionX_offset = sb->section2_offset + sb->section2_num * sb->cfg.section2_entry_size;
sb->sectionX_size = sb->section3_offset - sb->sectionX_offset; sb->sectionX_size = sb->bank_size - sb->sectionX_offset;
return 1; return 1;
fail: fail: