From e425876afe56564e82a528661438aa95857632a7 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+rprx@users.noreply.github.com> Date: Tue, 4 Aug 2020 03:50:22 +0000 Subject: [PATCH] Fix totalSize --- common/crypto/auth.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/crypto/auth.go b/common/crypto/auth.go index d1f1187d..2e64c811 100644 --- a/common/crypto/auth.go +++ b/common/crypto/auth.go @@ -248,13 +248,14 @@ func (w *AuthenticationWriter) seal(b []byte) (*buf.Buffer, error) { paddingSize = int32(w.padding.NextPaddingLen()) } - totalSize := encryptedSize + paddingSize + sizeBytes := w.sizeParser.SizeBytes() + totalSize := sizeBytes + encryptedSize + paddingSize if totalSize > buf.Size { return nil, newError("size too large: ", totalSize) } eb := buf.New() - w.sizeParser.Encode(uint16(encryptedSize+paddingSize), eb.Extend(w.sizeParser.SizeBytes())) + w.sizeParser.Encode(uint16(encryptedSize+paddingSize), eb.Extend(sizeBytes)) if _, err := w.auth.Seal(eb.Extend(encryptedSize)[:0], b); err != nil { eb.Release() return nil, err