Provide workaround for #196

This commit is contained in:
vit9696 2020-04-22 19:25:36 +03:00
parent fc2d8f07b1
commit cd110eafa6

View File

@ -3360,14 +3360,23 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index)
// Calculate digest for BG-protected ranges // Calculate digest for BG-protected ranges
UByteArray protectedParts; UByteArray protectedParts;
bool bgProtectedRangeFound = false; bool bgProtectedRangeFound = false;
try {
for (UINT32 i = 0; i < (UINT32)bgProtectedRanges.size(); i++) { for (UINT32 i = 0; i < (UINT32)bgProtectedRanges.size(); i++) {
if (bgProtectedRanges[i].Type == BG_PROTECTED_RANGE_INTEL_BOOT_GUARD_IBB) { if (bgProtectedRanges[i].Type == BG_PROTECTED_RANGE_INTEL_BOOT_GUARD_IBB && bgProtectedRanges[i].Size > 0) {
bgProtectedRangeFound = true; bgProtectedRangeFound = true;
if ((UINT64)bgProtectedRanges[i].Offset >= addressDiff) {
bgProtectedRanges[i].Offset -= (UINT32)addressDiff; bgProtectedRanges[i].Offset -= (UINT32)addressDiff;
} else {
// TODO: Explore this.
msg(usprintf("%s: Suspicious BG protection offset", __FUNCTION__), index);
}
protectedParts += openedImage.mid(bgProtectedRanges[i].Offset, bgProtectedRanges[i].Size); protectedParts += openedImage.mid(bgProtectedRanges[i].Offset, bgProtectedRanges[i].Size);
markProtectedRangeRecursive(index, bgProtectedRanges[i]); markProtectedRangeRecursive(index, bgProtectedRanges[i]);
} }
} }
} catch (...) {
bgProtectedRangeFound = false;
}
if (bgProtectedRangeFound) { if (bgProtectedRangeFound) {
UByteArray digest(SHA256_DIGEST_SIZE, '\x00'); UByteArray digest(SHA256_DIGEST_SIZE, '\x00');