Fix a version issue in ACBPv2 definition file

This commit is contained in:
Nikolaj Schlej 2022-09-10 16:08:06 +02:00
parent a9c6f347a2
commit c4ca232b3a
3 changed files with 11 additions and 15 deletions

View File

@ -278,12 +278,10 @@ USTATUS FitParser::parseFitEntryMicrocode(const UByteArray & microcode, const UI
USTATUS FitParser::parseFitEntryAcm(const UByteArray & acm, const UINT32 localOffset, const UModelIndex & parent, UString & info, UINT32 &realSize)
{
// Parse Intel ACM using Kaitai-generated parser
// TODO: need to do something with the copy here, probably implement a custom wrapper
try {
std::istringstream is(std::string(acm.constData(), acm.size()));
is.seekg(localOffset, is.beg);
kaitai::kstream ks(&is);
try {
intel_acm_t parsed(&ks);
intel_acm_t::header_t* header = parsed.header();
@ -396,11 +394,9 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif
{
U_UNUSED_PARAMETER(realSize);
// TODO: need to do something with the copy here, probably implement a custom wrapper
std::istringstream is(std::string(keyManifest.constData(), keyManifest.size()));
// v1
try {
std::istringstream is(std::string(keyManifest.constData(), keyManifest.size()));
is.seekg(localOffset, is.beg);
kaitai::kstream ks(&is);
intel_keym_v1_t parsed(&ks);
@ -469,6 +465,7 @@ USTATUS FitParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif
// v2
try {
std::istringstream is(std::string(keyManifest.constData(), keyManifest.size()));
is.seekg(localOffset, is.beg);
kaitai::kstream ks(&is);
intel_keym_v2_t parsed(&ks);
@ -564,11 +561,9 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic
{
U_UNUSED_PARAMETER(realSize);
// TODO: need to do something with the copy here, probably implement a custom wrapper
std::istringstream is(std::string(bootPolicy.constData(), bootPolicy.size()));
// v1
try {
std::istringstream is(std::string(bootPolicy.constData(), bootPolicy.size()));
is.seekg(localOffset, is.beg);
kaitai::kstream ks(&is);
intel_acbp_v1_t parsed(&ks);
@ -826,6 +821,7 @@ USTATUS FitParser::parseFitEntryBootGuardBootPolicy(const UByteArray & bootPolic
// v2
try {
std::istringstream is(std::string(bootPolicy.constData(), bootPolicy.size()));
is.seekg(localOffset, is.beg);
kaitai::kstream ks(&is);
intel_acbp_v2_t parsed(&ks); // This already verified the version to be >= 0x20

View File

@ -308,9 +308,6 @@ void intel_acbp_v2_t::pmda_entry_v3_t::_read() {
m_size = m__io->read_u4le();
m_total_entry_size = m__io->read_u2le();
m_version = m__io->read_u2le();
if (!(version() == 3)) {
throw kaitai::validation_not_equal_error<uint16_t>(3, version(), _io(), std::string("/types/pmda_entry_v3/seq/4"));
}
m_hash = new hash_t(m__io, this, m__root);
}
@ -421,6 +418,9 @@ void intel_acbp_v2_t::pmda_body_t::_read() {
m_reserved = m__io->read_u2le();
m_total_size = m__io->read_u2le();
m_version = m__io->read_u4le();
if (!(version() == 3)) {
throw kaitai::validation_not_equal_error<uint32_t>(3, version(), _io(), std::string("/types/pmda_body/seq/2"));
}
m_num_entries = m__io->read_u4le();
m_entries = new std::vector<pmda_entry_v3_t*>();
const int l_entries = num_entries();

View File

@ -90,7 +90,6 @@ types:
type: u2
- id: version
type: u2
valid: 3
- id: hash
type: hash
@ -102,6 +101,7 @@ types:
type: u2
- id: version
type: u4
valid: 3
- id: num_entries
type: u4
- id: entries