Skip to content

Commit 25f5b13

Browse files
authored
Fix Go Vet string conversion warnings (#185)
https://golang.org/doc/go1.15#vet
1 parent b59ed18 commit 25f5b13

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

attest/tpm.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ func readTPM2VendorAttributes(tpm io.ReadWriter) (tpm20Info, error) {
121121
return tpm20Info{}, fmt.Errorf("got capability of type %T, want tpm2.TaggedProperty", caps[0])
122122
}
123123
// Reconstruct the 4 ASCII octets from the uint32 value.
124-
vendorInfo += string(subset.Value&0xFF000000) + string(subset.Value&0xFF0000) + string(subset.Value&0xFF00) + string(subset.Value&0xFF)
124+
b := make([]byte, 4)
125+
binary.BigEndian.PutUint32(b, subset.Value)
126+
vendorInfo += string(b)
125127
}
126128

127129
caps, _, err := tpm2.GetCapability(tpm, tpm2.CapabilityTPMProperties, 1, tpmPtManufacturer)

attest/win_events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ func (w *WinEvents) parseUTF16(header microsoftEventHeader, r io.Reader) (string
636636
if err := binary.Read(r, binary.LittleEndian, &data); err != nil {
637637
return "", err
638638
}
639-
return strings.TrimSuffix(string(utf16.Decode(data)), string(0x00)), nil
639+
return strings.TrimSuffix(string(utf16.Decode(data)), "\x00"), nil
640640
}
641641

642642
func (w *WinEvents) readELAMAggregation(rdr *bytes.Reader, header microsoftEventHeader) error {

0 commit comments

Comments
 (0)