Skip to content

Commit e425876

Browse files
authored
Fix totalSize
1 parent 070e72f commit e425876

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

common/crypto/auth.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,14 @@ func (w *AuthenticationWriter) seal(b []byte) (*buf.Buffer, error) {
248248
paddingSize = int32(w.padding.NextPaddingLen())
249249
}
250250

251-
totalSize := encryptedSize + paddingSize
251+
sizeBytes := w.sizeParser.SizeBytes()
252+
totalSize := sizeBytes + encryptedSize + paddingSize
252253
if totalSize > buf.Size {
253254
return nil, newError("size too large: ", totalSize)
254255
}
255256

256257
eb := buf.New()
257-
w.sizeParser.Encode(uint16(encryptedSize+paddingSize), eb.Extend(w.sizeParser.SizeBytes()))
258+
w.sizeParser.Encode(uint16(encryptedSize+paddingSize), eb.Extend(sizeBytes))
258259
if _, err := w.auth.Seal(eb.Extend(encryptedSize)[:0], b); err != nil {
259260
eb.Release()
260261
return nil, err

0 commit comments

Comments
 (0)