diff --git a/pkg/uefi/biosregion.go b/pkg/uefi/biosregion.go index 13be3b52..016b501c 100644 --- a/pkg/uefi/biosregion.go +++ b/pkg/uefi/biosregion.go @@ -84,9 +84,7 @@ func NewBIOSRegion(buf []byte, r *FlashRegion, _ FlashRegionType) (Region, error RegionType: RegionTypeBIOS} var absOffset uint64 - // Copy the buffer - br.buf = make([]byte, len(buf)) - copy(br.buf, buf) + br.buf = buf for { offset := FindFirmwareVolumeOffset(buf) diff --git a/pkg/uefi/file.go b/pkg/uefi/file.go index c0fe9941..3254d537 100644 --- a/pkg/uefi/file.go +++ b/pkg/uefi/file.go @@ -416,10 +416,8 @@ func NewFile(buf []byte) (*File, error) { return nil, fmt.Errorf("File size too big! File with GUID: %v has length %v, but is only %v bytes big", f.Header.GUID, f.Header.ExtendedSize, buflen) } - // Copy out the buffer. - newBuf := buf[:f.Header.ExtendedSize] - f.buf = make([]byte, f.Header.ExtendedSize) - copy(f.buf, newBuf) + + f.buf = buf[:f.Header.ExtendedSize] // Special case for NVAR Store stored in raw file if f.Header.Type == FVFileTypeRaw && f.Header.GUID == *NVAR { diff --git a/pkg/uefi/firmwarevolume.go b/pkg/uefi/firmwarevolume.go index 9f571062..030b81fe 100644 --- a/pkg/uefi/firmwarevolume.go +++ b/pkg/uefi/firmwarevolume.go @@ -259,10 +259,7 @@ func NewFirmwareVolume(data []byte, fvOffset uint64, resizable bool) (*FirmwareV fv.FVType = FVGUIDs[fv.FileSystemGUID] fv.FVOffset = fvOffset - // copy out the buffer. - newBuf := data[:fv.Length] - fv.buf = make([]byte, fv.Length) - copy(fv.buf, newBuf) + fv.buf = data[:fv.Length] // Parse the files. // TODO: handle fv data alignment.