Fix Go Vet string conversion warnings (#185)

https://golang.org/doc/go1.15#vet
This commit is contained in:
Brandon Weeks 2020-11-19 07:25:44 +01:00 committed by GitHub
parent b59ed18da9
commit 25f5b13c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -121,7 +121,9 @@ func readTPM2VendorAttributes(tpm io.ReadWriter) (tpm20Info, error) {
return tpm20Info{}, fmt.Errorf("got capability of type %T, want tpm2.TaggedProperty", caps[0])
}
// Reconstruct the 4 ASCII octets from the uint32 value.
vendorInfo += string(subset.Value&0xFF000000) + string(subset.Value&0xFF0000) + string(subset.Value&0xFF00) + string(subset.Value&0xFF)
b := make([]byte, 4)
binary.BigEndian.PutUint32(b, subset.Value)
vendorInfo += string(b)
}
caps, _, err := tpm2.GetCapability(tpm, tpm2.CapabilityTPMProperties, 1, tpmPtManufacturer)

View File

@ -636,7 +636,7 @@ func (w *WinEvents) parseUTF16(header microsoftEventHeader, r io.Reader) (string
if err := binary.Read(r, binary.LittleEndian, &data); err != nil {
return "", err
}
return strings.TrimSuffix(string(utf16.Decode(data)), string(0x00)), nil
return strings.TrimSuffix(string(utf16.Decode(data)), "\x00"), nil
}
func (w *WinEvents) readELAMAggregation(rdr *bytes.Reader, header microsoftEventHeader) error {