Skip to content

Commit 8e9c749

Browse files
committed
Quick fix bgheader detection
Signed-off-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
1 parent 3100647 commit 8e9c749

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

pkg/intel/metadata/common/bgheader/bgheader.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,20 @@ func (bgv BootGuardVersion) String() string {
4040

4141
func DetectBGV(r io.Reader) (BootGuardVersion, error) {
4242
var s structInfo
43-
var bgv BootGuardVersion
44-
4543
err := binary.Read(r, binaryOrder, s.ID[:])
4644
if err != nil {
4745
return 0, fmt.Errorf("unable to read field 'ID': %w", err)
4846
}
49-
err = binary.Read(r, binaryOrder, bgv)
47+
err = binary.Read(r, binaryOrder, s.Version)
5048
if err != nil {
5149
return 0, fmt.Errorf("unable to read field 'Version': %w", err)
5250
}
53-
54-
return bgv, nil
51+
switch s.Version {
52+
case 0x10:
53+
return Version10, nil
54+
case 0x20:
55+
return Version20, nil
56+
default:
57+
return 0, fmt.Errorf("couldn't detect version")
58+
}
5559
}

0 commit comments

Comments
 (0)