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,13 +3360,22 @@ 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;
for (UINT32 i = 0; i < (UINT32)bgProtectedRanges.size(); i++) { try {
if (bgProtectedRanges[i].Type == BG_PROTECTED_RANGE_INTEL_BOOT_GUARD_IBB) { for (UINT32 i = 0; i < (UINT32)bgProtectedRanges.size(); i++) {
bgProtectedRangeFound = true; if (bgProtectedRanges[i].Type == BG_PROTECTED_RANGE_INTEL_BOOT_GUARD_IBB && bgProtectedRanges[i].Size > 0) {
bgProtectedRanges[i].Offset -= (UINT32)addressDiff; bgProtectedRangeFound = true;
protectedParts += openedImage.mid(bgProtectedRanges[i].Offset, bgProtectedRanges[i].Size); if ((UINT64)bgProtectedRanges[i].Offset >= addressDiff) {
markProtectedRangeRecursive(index, bgProtectedRanges[i]); 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);
markProtectedRangeRecursive(index, bgProtectedRanges[i]);
}
} }
} catch (...) {
bgProtectedRangeFound = false;
} }
if (bgProtectedRangeFound) { if (bgProtectedRangeFound) {