Skip to content

Commit 2df371d

Browse files
Merge pull request #6537 from oasisprotocol/martin/fix/pcs-quote-opaque-errors
go/common/sgx/pcs: Fix opaque errors
2 parents 4e40f52 + cfd329d commit 2df371d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

.changelog/6537.trivial.md

Whitespace-only changes.

go/common/sgx/pcs/quote.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func (q *Quote) UnmarshalBinary(data []byte) error {
5959
//
6060
// Returns the length of the decoded quote.
6161
func (q *Quote) UnmarshalBinaryWithTrailing(data []byte, allowTrailing bool) (int, error) {
62-
if len(data) < quoteHeaderLen+reportBodySgxLen+quoteSigSizeLen {
63-
return 0, fmt.Errorf("pcs/quote: invalid quote length")
62+
if minLen := quoteHeaderLen + reportBodySgxLen + quoteSigSizeLen; len(data) < minLen {
63+
return 0, fmt.Errorf("pcs/quote: invalid quote length: got %d, want at least %d bytes", len(data), minLen)
6464
}
6565

6666
// Quote Header.
@@ -98,8 +98,8 @@ func (q *Quote) UnmarshalBinaryWithTrailing(data []byte, allowTrailing bool) (in
9898
q.reportBody = &report
9999
offset += reportBodySgxLen
100100
case TeeTypeTDX:
101-
if len(data) < offset+reportBodyTdLen+quoteSigSizeLen {
102-
return 0, fmt.Errorf("pcs/quote: invalid quote length")
101+
if minLen := offset + reportBodyTdLen + quoteSigSizeLen; len(data) < minLen {
102+
return 0, fmt.Errorf("pcs/quote: invalid quote body length: got %d, want at least %d bytes", len(data), minLen)
103103
}
104104

105105
var report TdReport

0 commit comments

Comments
 (0)