Skip to content

Commit

Permalink
pkg/uefi/meregion: fall back so scanning whole region for FPT
Browse files Browse the repository at this point in the history
MEAnalyzer does the same thing. There are images where the
FPT is not at the beginning of the ME region, e.g.:
https://www.gigabyte.com/Motherboard/H410M-H-V3-rev-10-12/support#support-dl-bios

Signed-off-by: Daniel Maslowski <[email protected]>
  • Loading branch information
orangecms committed Sep 29, 2024
1 parent a957b05 commit a5214b3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/uefi/meregion.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ func (e MEPartitionEntry) Type() string {

// FindMEDescriptor searches for an Intel ME FPT signature
func FindMEDescriptor(buf []byte) (int, error) {
if bytes.Equal(buf[16:16+len(MEFPTSignature)], MEFPTSignature) {
// 16 + 4 since the descriptor starts after the signature
return 16 + len(MEFPTSignature), nil
}
if bytes.Equal(buf[:len(MEFPTSignature)], MEFPTSignature) {
// + 4 since the descriptor starts after the signature
return len(MEFPTSignature), nil
// In some images, the signature may occur right at the start,
// in other, it occurs in the second 16 bytes, and
// in some cases, it appears somewhere else in the ME region.
// NOTE: This library excludes the signature from the descriptor.
fptOffset := bytes.Index(buf, MEFPTSignature)
if fptOffset > 0 {
return fptOffset + len(MEFPTSignature), nil
}
return -1, fmt.Errorf("ME Flash Partition Table signature %#02x not found: first 20 bytes are:\n%s", MEFPTSignature, hex.Dump(buf[:20]))
}
Expand Down

0 comments on commit a5214b3

Please sign in to comment.