mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 16:08:23 +08:00
Fix using temporary after scope in FfsParser::parseVendorHashFile
This commit is contained in:
parent
bf3adbe4c6
commit
4d948475d8
@ -3522,17 +3522,20 @@ USTATUS FfsParser::parseVendorHashFile(const UByteArray & fileGuid, const UModel
|
|||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (fileGuid == BG_VENDOR_HASH_FILE_GUID_PHOENIX) {
|
if (fileGuid == BG_VENDOR_HASH_FILE_GUID_PHOENIX) {
|
||||||
|
const UByteArray &body = model->body(index);
|
||||||
|
UINT32 size = (UINT32)body.size();
|
||||||
|
|
||||||
// File too small to have even a signature
|
// File too small to have even a signature
|
||||||
if ((UINT32)model->body(index).size() < sizeof(BG_VENDOR_HASH_FILE_SIGNATURE_PHOENIX)) {
|
if (size < sizeof(BG_VENDOR_HASH_FILE_SIGNATURE_PHOENIX)) {
|
||||||
msg(usprintf("%s: unknown or corrupted Phoenix hash file found", __FUNCTION__), index);
|
msg(usprintf("%s: unknown or corrupted Phoenix hash file found", __FUNCTION__), index);
|
||||||
model->setText(index, UString("Phoenix hash file"));
|
model->setText(index, UString("Phoenix hash file"));
|
||||||
return U_INVALID_FILE;
|
return U_INVALID_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BG_VENDOR_HASH_FILE_HEADER_PHOENIX* header = (const BG_VENDOR_HASH_FILE_HEADER_PHOENIX*)model->body(index).constData();
|
const BG_VENDOR_HASH_FILE_HEADER_PHOENIX* header = (const BG_VENDOR_HASH_FILE_HEADER_PHOENIX*)body.constData();
|
||||||
if (header->Signature == BG_VENDOR_HASH_FILE_SIGNATURE_PHOENIX) {
|
if (header->Signature == BG_VENDOR_HASH_FILE_SIGNATURE_PHOENIX) {
|
||||||
if ((UINT32)model->body(index).size() < sizeof(BG_VENDOR_HASH_FILE_HEADER_PHOENIX) ||
|
if (size < sizeof(BG_VENDOR_HASH_FILE_HEADER_PHOENIX) ||
|
||||||
(UINT32)model->body(index).size() < sizeof(BG_VENDOR_HASH_FILE_HEADER_PHOENIX) + header->NumEntries * sizeof(BG_VENDOR_HASH_FILE_ENTRY)) {
|
size < sizeof(BG_VENDOR_HASH_FILE_HEADER_PHOENIX) + header->NumEntries * sizeof(BG_VENDOR_HASH_FILE_ENTRY)) {
|
||||||
msg(usprintf("%s: unknown or corrupted Phoenix hash file found", __FUNCTION__), index);
|
msg(usprintf("%s: unknown or corrupted Phoenix hash file found", __FUNCTION__), index);
|
||||||
model->setText(index, UString("Phoenix hash file"));
|
model->setText(index, UString("Phoenix hash file"));
|
||||||
return U_INVALID_FILE;
|
return U_INVALID_FILE;
|
||||||
@ -3575,14 +3578,15 @@ USTATUS FfsParser::parseVendorHashFile(const UByteArray & fileGuid, const UModel
|
|||||||
}
|
}
|
||||||
else if (fileGuid == BG_VENDOR_HASH_FILE_GUID_AMI) {
|
else if (fileGuid == BG_VENDOR_HASH_FILE_GUID_AMI) {
|
||||||
UModelIndex fileIndex = model->parent(index);
|
UModelIndex fileIndex = model->parent(index);
|
||||||
UINT32 size = model->body(index).size();
|
const UByteArray &body = model->body(index);
|
||||||
if (size != (UINT32)model->body(index).count('\xFF')) {
|
UINT32 size = (UINT32)body.size();
|
||||||
|
if (size != (UINT32)body.count('\xFF')) {
|
||||||
if (size == sizeof(BG_VENDOR_HASH_FILE_HEADER_AMI_NEW)) {
|
if (size == sizeof(BG_VENDOR_HASH_FILE_HEADER_AMI_NEW)) {
|
||||||
bool protectedRangesFound = false;
|
bool protectedRangesFound = false;
|
||||||
UINT32 NumEntries = (UINT32)model->body(index).size() / sizeof(BG_VENDOR_HASH_FILE_ENTRY);
|
UINT32 NumEntries = (UINT32)body.size() / sizeof(BG_VENDOR_HASH_FILE_ENTRY);
|
||||||
for (UINT32 i = 0; i < NumEntries; i++) {
|
for (UINT32 i = 0; i < NumEntries; i++) {
|
||||||
protectedRangesFound = true;
|
protectedRangesFound = true;
|
||||||
const BG_VENDOR_HASH_FILE_ENTRY* entry = (const BG_VENDOR_HASH_FILE_ENTRY*)(model->body(index).constData()) + i;
|
const BG_VENDOR_HASH_FILE_ENTRY* entry = (const BG_VENDOR_HASH_FILE_ENTRY*)(body.constData()) + i;
|
||||||
BG_PROTECTED_RANGE range;
|
BG_PROTECTED_RANGE range;
|
||||||
range.Offset = entry->Offset;
|
range.Offset = entry->Offset;
|
||||||
range.Size = entry->Size;
|
range.Size = entry->Size;
|
||||||
@ -3594,7 +3598,7 @@ USTATUS FfsParser::parseVendorHashFile(const UByteArray & fileGuid, const UModel
|
|||||||
if (protectedRangesFound) {
|
if (protectedRangesFound) {
|
||||||
securityInfo += usprintf("New AMI hash file found at base %Xh\nProtected ranges:", model->base(fileIndex));
|
securityInfo += usprintf("New AMI hash file found at base %Xh\nProtected ranges:", model->base(fileIndex));
|
||||||
for (UINT32 i = 0; i < NumEntries; i++) {
|
for (UINT32 i = 0; i < NumEntries; i++) {
|
||||||
const BG_VENDOR_HASH_FILE_ENTRY* entry = (const BG_VENDOR_HASH_FILE_ENTRY*)(model->body(index).constData()) + i;
|
const BG_VENDOR_HASH_FILE_ENTRY* entry = (const BG_VENDOR_HASH_FILE_ENTRY*)(body.constData()) + i;
|
||||||
securityInfo += usprintf("\nAddress: %08Xh Size: %Xh\nHash: ", entry->Offset, entry->Size);
|
securityInfo += usprintf("\nAddress: %08Xh Size: %Xh\nHash: ", entry->Offset, entry->Size);
|
||||||
for (UINT8 j = 0; j < sizeof(entry->Hash); j++) {
|
for (UINT8 j = 0; j < sizeof(entry->Hash); j++) {
|
||||||
securityInfo += usprintf("%02X", entry->Hash[j]);
|
securityInfo += usprintf("%02X", entry->Hash[j]);
|
||||||
@ -3607,7 +3611,7 @@ USTATUS FfsParser::parseVendorHashFile(const UByteArray & fileGuid, const UModel
|
|||||||
}
|
}
|
||||||
else if (size == sizeof(BG_VENDOR_HASH_FILE_HEADER_AMI_OLD)) {
|
else if (size == sizeof(BG_VENDOR_HASH_FILE_HEADER_AMI_OLD)) {
|
||||||
securityInfo += usprintf("Old AMI hash file found at base %Xh\nProtected range:", model->base(fileIndex));
|
securityInfo += usprintf("Old AMI hash file found at base %Xh\nProtected range:", model->base(fileIndex));
|
||||||
const BG_VENDOR_HASH_FILE_HEADER_AMI_OLD* entry = (const BG_VENDOR_HASH_FILE_HEADER_AMI_OLD*)(model->body(index).constData());
|
const BG_VENDOR_HASH_FILE_HEADER_AMI_OLD* entry = (const BG_VENDOR_HASH_FILE_HEADER_AMI_OLD*)(body.constData());
|
||||||
securityInfo += usprintf("\nSize: %Xh\nHash: ", entry->Size);
|
securityInfo += usprintf("\nSize: %Xh\nHash: ", entry->Size);
|
||||||
for (UINT8 i = 0; i < sizeof(entry->Hash); i++) {
|
for (UINT8 i = 0; i < sizeof(entry->Hash); i++) {
|
||||||
securityInfo += usprintf("%02X", entry->Hash[i]);
|
securityInfo += usprintf("%02X", entry->Hash[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user